기타

파이썬 import kafka (six) ModuleNotFoundError 에러

99duuk 2025. 1. 6. 15:00
/Users/tars/PycharmProjects/di_mock_engine/.venv/bin/python /Users/tars/PycharmProjects/di_mock_engine/engine.py 
Traceback (most recent call last):
  File "/Users/tars/PycharmProjects/di_mock_engine/engine.py", line 1, in <module>
    from kafka import KafkaConsumer, KafkaProducer
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/__init__.py", line 23, in <module>
    from kafka.consumer import KafkaConsumer
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/consumer/__init__.py", line 3, in <module>
    from kafka.consumer.group import KafkaConsumer
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/consumer/group.py", line 13, in <module>
    from kafka.consumer.fetcher import Fetcher
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/consumer/fetcher.py", line 19, in <module>
    from kafka.record import MemoryRecords
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/record/__init__.py", line 1, in <module>
    from kafka.record.memory_records import MemoryRecords, MemoryRecordsBuilder
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/record/memory_records.py", line 27, in <module>
    from kafka.record.legacy_records import LegacyRecordBatch, LegacyRecordBatchBuilder
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/record/legacy_records.py", line 50, in <module>
    from kafka.codec import (
    ...<2 lines>...
    )
  File "/Users/tars/PycharmProjects/di_mock_engine/.venv/lib/python3.13/site-packages/kafka/codec.py", line 9, in <module>
    from kafka.vendor.six.moves import range
ModuleNotFoundError: No module named 'kafka.vendor.six.moves'

Process finished with exit code 1

멀쩡히 잘 돌아가다가 뭐 좀 바꿨더니 갑자기 안돌아간다 

현재 오류는 kafka 라이브러리가 필요한 의존성 모듈인 six을 찾지 못해서 발생한 것입니다. 이는 six 모듈이 설치되지 않았거나 올바르게 로드되지 않았기 때문입니다.


지피티가 패키지 잘못이랬다가 가상환경 잘못이랬다가 ssl 잘못이랬다가 환경변수 잘못이랬다가 뭐 어쩌구저쩌구 파이썬을 재설치해야하느니 파이참 설정 문제라느니

이거 바꿨다가 저거 초기화했다가 받았다가 지웠다가 어쩌고저저고

화가 잔뜩 나다가 
쎄한 지피티의 대답에 구글링 냅다 해봤더니 

https://github.com/dpkp/kafka-python/issues/2412

 

"import kafka" fails with "ModuleNotFoundError: No module named 'kafka.vendor.six.moves'" under Python 3.12 · Issue #2412 · dp

I have verified this on Linux and Windows, even though the output below is from Linux: user1@CY1-WL-337:~/dev$ python3.12 -m venv venv user1@CY1-WL-337:~/dev$ source venv/bin/activate (venv) user1@...

github.com

 

올리버쌤이 알려준대로 했더니 

된다.. 

올리버쌤.. 

소당큐~~~

'기타' 카테고리의 다른 글

Redis의 Sorted Set이 조회 횟수를 저장하는 원리 (검색 순위)  (0) 2025.01.12
단상 2  (0) 2025.01.07
쿠키 옵션  (2) 2024.12.26
Materialized Path - 계층적 데이터 표현...  (0) 2024.12.10
tar와 zip의 차이  (2) 2024.12.06