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,但是它一直抛出错误模块,没有找到。我已经完成了并下载了它,但是它似乎是python的错误版本。如何选择要安装的pip的正确选项?我正在使用VSCode
pip安装openai
发布于 2022-11-04 01:42:37
尝试使用pip3 install openai
,因为它为python3安装openai,而不是python2 (如果您安装了它)。如果只有python3,pip和pip3基本上是一样的(我认为)。
发布于 2022-11-04 01:47:16
按照下面的步骤安装当前解释器的openai
包
导入sys print(sys.executable)
openai
C:\WorkSpace\pytest10.venv\Scripts\python.exe -m pip安装openai
将上面命令中的路径修改为您获得的解释器路径。
https://stackoverflow.com/questions/74311275
复制相似问题