ModuleNotFoundError: No module named ‘openai.error‘

简介: 这篇文章讨论了在使用OpenAI库时遇到的`ModuleNotFoundError: No module named ‘openai.error'`错误,并提供了两种解决方案:将OpenAI版本降级到0.28.0或修改代码以去掉对`openai.error`的引用并将异常处理放置到`openai`模块下。

ModuleNotFoundError: No module named ‘openai.error’

result = self.fn(*self.args, **self.kwargs) File “H:\chatGPTWeb\chatgpt-on-wechat\channel\chat_channel.py”, line 168,
in _handle
reply = self._generate_reply(context) File “H:\chatGPTWeb\chatgpt-on-wechat\channel\chat_channel.py”, line 178,
in _generate_reply
e_context = PluginManager().emit_event( File “H:\chatGPTWeb\chatgpt-on-wechat\plugins\plugin_manager.py”, line 189,
in emit_event
instance.handlers[e_context.event](e_context, *args, **kwargs) File “H:\chatGPTWeb\chatgpt-on-wechat\plugins\role\role.py”, line 104,
in on_handle_context
bot = Bridge().get_bot(“chat”) File “H:\chatGPTWeb\chatgpt-on-wechat\bridge\bridge.py”, line 53, in
get_bot
self.bots[typename] = create_bot(self.btype[typename]) File “H:\chatGPTWeb\chatgpt-on-wechat\bot\bot_factory.py”, line 22, in
create_bot
from bot.chatgpt.chat_gpt_bot import ChatGPTBot File “H:\chatGPTWeb\chatgpt-on-wechat\bot\chatgpt\chat_gpt_bot.py”, line 6,
in
import openai.error ModuleNotFoundError: No module named ‘openai.error’

1、错误原因

Openai升级之后,openai.error 被去掉了。
参考解决方案:https://github.com/openai/openai-python/issues/840(访问前请注意上网环境)

2、修复方法

  1. Openai版本 退到0.28.0
  2. 把openai.error去掉,然后下面的异常放置到openai下访问。在这里插入图片描述在这里插入图片描述
相关文章
|
3月前
|
人工智能 语音技术
ModuleNotFoundError: AutomaticSpeechRecognitionPipeline: No module named ‘funasr‘
这篇文章描述了在运行阿里语音AI模型的语音识别时遇到的`ModuleNotFoundError: No module named ‘funasr’`错误,并提供了通过`pip install funasr --upgrade -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html`命令重新安装funasr模块的解决方法。
ModuleNotFoundError: AutomaticSpeechRecognitionPipeline: No module named ‘funasr‘
|
12月前
Py3 ModuleNotFoundError: No module named ‘Crypto‘;ModuleNotFoundError: No module named Cryptodome‘
Py3 ModuleNotFoundError: No module named ‘Crypto‘;ModuleNotFoundError: No module named Cryptodome‘
94 0
|
6月前
|
Linux PyTorch 算法框架/工具
[已解决]ModuleNotFoundError: No module named ‘einops‘
[已解决]ModuleNotFoundError: No module named ‘einops‘
ModuleNotFoundError: No module named ‘exceptions‘
ModuleNotFoundError: No module named ‘exceptions‘
ModuleNotFoundError: No module named ‘sentencepiece‘
ModuleNotFoundError: No module named ‘sentencepiece‘
235 0
ModuleNotFoundError: No module named ‘pydensecrf‘解决办法
ModuleNotFoundError: No module named ‘pydensecrf‘解决办法
313 0
|
TensorFlow 算法框架/工具 Python
成功解决ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
成功解决ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
ModuleNotFoundError: No module named 'torchstat'
ModuleNotFoundError: No module named 'torchstat'
446 0
ModuleNotFoundError: No module named 'torchstat'
|
Python
ModuleNotFoundError: No module named ‘pyexpat‘
ModuleNotFoundError: No module named ‘pyexpat‘
217 0
|
计算机视觉 C++ Python
解决ModuleNotFoundError: No module named ‘skimage‘问题
解决ModuleNotFoundError: No module named ‘skimage‘问题
2652 0
解决ModuleNotFoundError: No module named ‘skimage‘问题