問(wèn)題描述:
運(yùn)行openai編寫的代碼,發(fā)現(xiàn)報(bào)如下錯(cuò)誤:
Traceback (most recent call last):
File "文字輸入_prompt.py", line 40, in <module>
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'
出現(xiàn)原因
openai安裝版本不是最新導(dǎo)致,更新到最新版本就可以解決。(最新版需要到0.27.0)
解決方案
把openai更新到最新版就可以解決:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-507687.html
- 自動(dòng)安裝:
pip3 install --upgrade openai
- 或者手動(dòng)安裝:
- 從:https://pypi.org/project/openai/#files下載
openai-0.27.0-py3-none-any.whl
- 然后安裝:
pip3 install openai-0.27.0-py3-none-any.whl
- 從:https://pypi.org/project/openai/#files下載
參考地址:https://github.com/openai/openai-python/issues/246文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-507687.html
到了這里,關(guān)于運(yùn)行openai遇到:module ‘openai‘ has no attribute ‘ChatCompletion‘ 解決方案的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!