英文:
import openai fails (python): cannot import name 'COMMON_SAFE_ASCII_CHARACTERS'
问题
Here is the translated code section without the error messages:
Trying to use openai:
import openai
英文:
Trying to use openai:
import openai
I've got the following errors:
Traceback (most recent call last):
File "/.../lib/python3.11/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 "/.../chat.py", line 1, in <module>
import openai
File "/.../lib/python3.11/site-packages/openai/__init__.py", line 9, in <module>
from openai.api_resources import (
File "/.../lib/python3.11/site-packages/openai/api_resources/__init__.py", line 1, in <module>
from openai.api_resources.audio import Audio # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../lib/python3.11/site-packages/openai/api_resources/audio.py", line 4, in <module>
from openai import api_requestor, util
File "/.../lib/python3.11/site-packages/openai/api_requestor.py", line 21, in <module>
import aiohttp
File "/.../lib/python3.11/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import (
File "/.../lib/python3.11/site-packages/aiohttp/client.py", line 59, in <module>
from .client_reqrep import (
File "/.../lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 72, in <module>
import charset_normalizer as chardet # type: ignore[no-redef]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../lib/python3.11/site-packages/charset_normalizer/__init__.py", line 23, in <module>
from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
File "/.../lib/python3.11/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' (/.../lib/python3.11/site-packages/charset_normalizer/constant.py)
答案1
得分: 2
这是一个依赖性问题。安装 charset-normalizer 版本 2.1.0:
python -m pip install charset-normalizer==2.1.0
英文:
It's a dependancy problem. Install charset-normalizer version 2.1.0:
python -m pip install charset-normalizer==2.1.0
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论