gpt4 book ai didi

python - 模块未找到错误 : No Module Named openai

转载 作者:行者123 更新时间:2023-12-02 18:01:26 31 4
gpt4 key购买 nike

import requests
from bs4 import BeautifulSoup
import openai

#write each line of nuclear.txt to a list
with open('nuclear.txt', 'r') as f:
lines = f.readlines()

#remove the newline character from each line
lines = [line.rstrip() for line in lines]

#gather the text from each website and add it to a new txt file
for line in lines:
r = requests.get(line)
soup = BeautifulSoup(r.text, 'html.parser')
text = soup.get_text()
with open('nuclear_text.txt', 'a') as f:
f.write(text)

我正在尝试导入 openai,但它一直抛出错误模块未找到。我已经完成 pip install openai 并下载了它,但它似乎是错误的 python 版本。如何为 pip 选择正确的安装位置?我正在使用 VSCode

pip安装openai

最佳答案

尝试使用 pip3 install openai,因为它会为 python3 安装 openai,而不是 python2(如果你安装了它)。如果你只有 python3,pip 和 pip3 基本上是一回事(我认为)。

关于python - 模块未找到错误 : No Module Named openai,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74311275/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com