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)
I'm trying to import openai, however it keeps throwing the error module not found. I have done pip install openai and it downloads, but it appears to be the wrong version of python. How do I select the correct one for pip to install to? I am using VSCode
pip install openai
openai
package for the current interpreterrun the following code
import sys
print(sys.executable)
get the current interpreter path
Copy the path and install openai
using the following command in the terminal
C:\WorkSpace\pytest10\.venv\Scripts\python.exe -m pip install openai
Modify the path in the above command to the interpreter path you got.