运行openai编写的代码,发现报如下错误:
Traceback (most recent call last):
File "文字输入_prompt.py", line 40, in
ans = openai_reply('openai secret key')
File "文字输入_prompt.py", line 18, in openai_reply
response = openai.ChatCompletion.create(
AttributeError: module 'openai' has no attribute 'ChatCompletion'
openai安装版本不是最新导致,更新到最新版本就可以解决。(最新版需要到0.27.0)
把openai更新到最新版就可以解决:
pip3 install --upgrade openai
openai-0.27.0-py3-none-any.whl
pip3 install openai-0.27.0-py3-none-any.whl
参考地址:https://github.com/openai/openai-python/issues/246