Stackoverflow/Python

ModuleNotFoundError: No module named 'cchardet'

The Neo 2024. 2. 1. 09:08

에러 메세지

D:\anaconda3\envs\gpt\python.exe D:/gpt/_openai.py
Traceback (most recent call last):
  File "D:\anaconda3\envs\gpt\lib\site-packages\aiohttp\client_reqrep.py", line 70, in <module>
    import cchardet as chardet
ModuleNotFoundError: No module named 'cchardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/gpt/_openai.py", line 2, in <module>
    import openai
  File "D:\anaconda3\envs\gpt\lib\site-packages\openai\__init__.py", line 15, in <module>
    import aiohttp
  File "D:\anaconda3\envs\gpt\lib\site-packages\aiohttp\__init__.py", line 6, in <module>
    from .client import (
  File "D:\anaconda3\envs\gpt\lib\site-packages\aiohttp\client.py", line 59, in <module>
    from .client_reqrep import (
  File "D:\anaconda3\envs\gpt\lib\site-packages\aiohttp\client_reqrep.py", line 72, in <module>
    import charset_normalizer as chardet  # type: ignore[no-redef]
  File "D:\anaconda3\envs\gpt\lib\site-packages\charset_normalizer\__init__.py", line 23, in <module>
    from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
  File "D:\anaconda3\envs\gpt\lib\site-packages\charset_normalizer\api.py", line 10, in <module>
    from charset_normalizer.md import mess_ratio
  File "charset_normalizer\md.py", line 5, in <module>
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (D:\anaconda3\envs\gpt\lib\site-packages\charset_normalizer\constant.py)

Process finished with exit code 1

 

openai를 python으로 테스트 하기 위해서 코드를 짜봤으나, 에러가 발생하였다.

에러를 읽어보니, Charset에 대한 에러로 아래와 같이 해결이 가능하다.

 

해결방안

pip install cchardet

 

chardet도 있지만, 여기서 에러는 cchardet이라는 것을 명심해야 한다.

 

 

반응형