-
module 'collections' has no attribute 'Container' 파이썬 오류IT 2023. 7. 13. 00:11반응형
파이썬의 collections 모듈에는 Container라는 속성이 없습니다. Container는 Python 2.x 버전에서 collections 모듈에 포함된 속성이었으나, Python 3.x 버전에서는 제거되었습니다. 따라서, Python 3.x 버전을 사용하고 있다면 해당 속성을 사용할 수 없습니다.
오류 메시지 "module 'collections' has no attribute 'Container'"는 코드에서 collections.Container를 참조하려고 할 때 발생하는 것입니다. 이 오류는 코드를 Python 3.x 버전에 맞게 수정해야 합니다.
Python 3.x에서는 collections 모듈에 대부분의 속성이 그대로 유지되었지만, Container 대신 collections.abc 모듈에서 Container의 기능을 사용할 수 있습니다. 따라서 코드를 수정하여 collections.abc.Container를 사용하면 됩니다.
예를 들어, isinstance(obj, collections.Container)와 같은 코드를 사용하던 경우를 isinstance(obj, collections.abc.Container)로 변경하면 됩니다.
요약하면, "module 'collections' has no attribute 'Container'" 오류는 Python 3.x 버전에서 collections.Container를 사용하려고 할 때 발생하며, Python 3.x에 맞게 collections.abc.Container로 수정해야 합니다.반응형'IT' 카테고리의 다른 글
[파이썬] 인강 자동으로 넘기기 (0) 2023.07.14 파이썬 3.9버전 다운받기 (0) 2023.07.13 [파이썬] Tkinter에서 리스트박스 내 순서 변경하는 방법 (0) 2023.07.12 엑셀 유용한 단축키 소개 (0) 2023.07.12 파이썬으로 똥피하기 게임 만들기 (0) 2023.07.12