国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

運(yùn)行openai遇到:module ‘openai‘ has no attribute ‘ChatCompletion‘ 解決方案

這篇具有很好參考價(jià)值的文章主要介紹了運(yùn)行openai遇到:module ‘openai‘ has no attribute ‘ChatCompletion‘ 解決方案。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

問(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)
運(yùn)行openai遇到:module ‘openai‘ has no attribute ‘ChatCompletion‘ 解決方案

解決方案

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

  • 自動(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://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)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • python遇到AttributeError: module ‘XXX‘ has no attribute ‘XXX‘的錯(cuò)誤,解決辦法

    錯(cuò)誤原因: 主要的原因看可能有3個(gè): 1、檢查一下有沒(méi)有拼錯(cuò)函數(shù),有時(shí)候?qū)懙目炝苏娴挠锌赡苁终`; 2、如果沒(méi)拼錯(cuò)那就檢測(cè)一下該模塊的函數(shù)是否是更新了,因?yàn)閜ython的第三方庫(kù)是時(shí)常會(huì)更新的,有時(shí)候函數(shù)名會(huì)有輕微的變動(dòng)這也很正常,解決方法就是查看一下對(duì)應(yīng)版本

    2024年04月12日
    瀏覽(23)
  • Python中使用OpenCV讀取灰度圖像時(shí)遇到的錯(cuò)誤:module ‘cv2‘ has no attribute ‘CV_LOAD_IMAGE_GRAYSCA...

    Python中使用OpenCV讀取灰度圖像時(shí)遇到的錯(cuò)誤:module ‘cv2’ has no attribute ‘CV_LOAD_IMAGE_GRAYSCALE’。 OpenCV是一款廣泛應(yīng)用于計(jì)算機(jī)視覺領(lǐng)域的開源計(jì)算機(jī)視覺庫(kù),它可以實(shí)現(xiàn)圖像處理、分析、識(shí)別等功能。而在使用OpenCV讀取灰度圖像時(shí),可能會(huì)出現(xiàn)上述錯(cuò)誤。 這個(gè)錯(cuò)誤發(fā)生的原

    2024年02月16日
    瀏覽(23)
  • module ‘numpy‘ has no attribute ‘int‘

    module \\\'numpy\\\' has no attribute \\\'int\\\' 臨時(shí)解決方法: pip install numpy==1.23 警告: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the pre

    2024年02月12日
    瀏覽(25)
  • module ‘numpy‘ has no attribute ‘object‘.

    np.object was a deprecated alias for the builtin object . To avoid this error in existing code, use object by itself. Doing this will not modify any behavior and is safe. 高版本的numpy np.object棄用了,把np.object改成object,或者降低numpy版本

    2024年02月15日
    瀏覽(26)
  • AttributeError: module ‘torch.nn‘ has no attribute ‘module‘

    AttributeError: module ‘torch.nn‘ has no attribute ‘module‘

    如上,調(diào)用時(shí)報(bào)錯(cuò): init () takes 1 positional argument but 2 were given 糾錯(cuò)發(fā)現(xiàn)是少打了下劃線 init前后有兩個(gè)_,

    2024年02月16日
    瀏覽(27)
  • 解決AttributeError: module ‘keras‘ has no attribute ……

    在成功解決AttributeError: module ‘keras‘ has no attribute ‘utils‘_new1998的博客-CSDN博客這篇博客中博主有提到如何解決這一問(wèn)題,其中就是要把 更改成為 而博主不知道其中原因,原因其實(shí)是在TensorFlow 2.4及以上版本中, import keras 的方式已經(jīng)被棄用,取而代之的是 import tensorflow.k

    2024年02月11日
    瀏覽(31)
  • AttributeError: module ‘torch‘ has no attribute ‘concat‘

    AttributeError: module ‘torch‘ has no attribute ‘concat‘

    ? ? 如圖上所示報(bào)錯(cuò)地方 在跑算法代碼的時(shí)候,發(fā)現(xiàn)報(bào)錯(cuò),但是這個(gè)錯(cuò)誤在網(wǎng)上沒(méi)有找到,我推測(cè)是pytorch改版問(wèn)題,于是查看torch版本改動(dòng),發(fā)現(xiàn)torch.concat改版后該寫為torch.cat。不過(guò)或許我寫的也不夠準(zhǔn)確,除此之外還看到了有人問(wèn)torch.concat和torch.cat的區(qū)別。 ? ? 不過(guò)出現(xiàn)

    2024年02月16日
    瀏覽(53)
  • AttributeError: module ‘collections‘ has no attribute ‘MutableMapping‘

    AttributeError: module ‘collections‘ has no attribute ‘MutableMapping‘

    今天在裝live server時(shí)遇到如下兩個(gè)問(wèn)題。 module ‘collections’ has no attribute ‘MutableSet’ AttributeError: module ‘collections’ has no attribute ‘MutableMapping’ 部分錯(cuò)誤結(jié)果如下: 網(wǎng)上找了好多都是把問(wèn)題貼出來(lái)然后就沒(méi)下文了,琢磨了三四個(gè)小時(shí)幸虧解決了?。?yīng)該是python 3.10 那些 M

    2024年02月13日
    瀏覽(26)
  • AttributeError: module ‘numpy‘ has no attribute ‘float‘

    出現(xiàn)這個(gè)問(wèn)題的原因是:從numpy1.24起刪除了numpy.bool、numpy.int、numpy.float、numpy.complex、numpy.object、numpy.str、numpy.long、numpy.unicode類型的支持。解決上訴問(wèn)題主要有兩種方法: 安裝numpy1.24之前的版本 可以用python內(nèi)置類型或者np.ndarray類型替換: np.float替換為float或者np.float64/np.fl

    2024年02月11日
    瀏覽(25)
  • AttributeError: module ‘distutils‘ has no attribute ‘version‘

    問(wèn)題: AttributeError: module ‘distutils’ has no attribute ‘version’. 解決: setuptools版本問(wèn)題”,版本過(guò)高導(dǎo)致的問(wèn)題;setuptools版本 第一步: pip uninstall setuptools 【使用pip,不能使用 conda uninstall setuptools ; 【不能使用conda的命令,原因是,conda在卸載的時(shí)候,會(huì)自動(dòng)分析與其相關(guān)的庫(kù)

    2024年02月16日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包