【问题标题】:How to fix the error : "cannot import name 'GPT' from "gpt"如何修复错误:“无法从“gpt”导入名称“GPT”
【发布时间】:2021-09-27 08:46:38
【问题描述】:

当我在 Google Colab 中运行以下代码时,出现以下错误。

注意:我已经使用 pip (!pip install gpt) 安装了 gpt。

代码

from gpt import GPT
from gpt import Example'

错误

cannot import name 'GPT' from 'gpt' (/usr/local/lib/python3.7/dist-packages/gpt/__init__.py)

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 你能给我们一个文档/github的链接吗?您到底在寻找什么?
  • 我正在关注 Bhat Bavesh 的教程,可以在这里找到:github.com/bhattbhavesh91/gpt-3-simple-tutorial/blob/master/…,他正在使用 GPT-3 模型制作 pandas 自动代码生成器。
  • 你需要克隆那个 github 仓库并直接从 gpt.py 导入 GPT 类

标签: python gpt-3


【解决方案1】:

这是因为你还没有从 GitHub 仓库导入gpt.py

你可以找到它here

  • 确保将gpt.py 保存在当前工作文件夹中
  • 不要忘记将您的 API 密钥命名为 openai.api_key,因为它是 gpt.py 中 API 密钥的变量

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-02
    • 2020-04-24
    • 2019-12-30
    • 1970-01-01
    • 2018-02-14
    • 2019-11-27
    • 2015-02-05
    • 2019-12-19
    相关资源
    最近更新 更多