无法导入名为 ‘COMMON_SAFE_ASCII_CHARACTERS’ 的项目。

huangapple go评论75阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年5月17日 20:46:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76272281.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定