• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

运行openai遇到module ‘openai‘ has no attribute ‘ChatCompletion‘ 解决方案

武飞扬头像
【文言】
帮助1

问题描述:

运行openai编写的代码,发现报如下错误:

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'

出现原因

openai安装版本不是最新导致,更新到最新版本就可以解决。(最新版需要到0.27.0)
学新通

解决方案

把openai更新到最新版就可以解决:

  • 自动安装:pip3 install --upgrade openai
  • 或者手动安装:

参考地址:https://github.com/openai/openai-python/issues/246

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhiagjgh
系列文章
更多 icon
同类精品
更多 icon
继续加载