当前位置: 首页 > news >正文

ModuleNotFoundError: No Module Named openai

题意:Python 无法在环境中找到名为 openai 的模块

问题背景:

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

我尝试导入 openai 模块,但它一直抛出“模块未找到”的错误。我已经执行了 pip install openai 并且它下载了,但似乎它安装在了错误的 Python 版本上。我该如何为 pip 选择正确的 Python 版本来安装?我正在使用 VSCode。

pip install openai

问题解决:

Follow the steps below to install the openai package for the current interpreter

按照以下步骤为当前解释器安装 openai 包

1. run the following code        运行以下的代码

import sys
print(sys.executable)

2. get the current interpreter path        获取当前解释器路径

3. Copy the path and install openai using the following command in the terminal

复制该路径并在终端中使用以下命令安装 openai

C:\WorkSpace\pytest10\.venv\Scripts\python.exe -m pip install openai

Modify the path in the above command to the interpreter path you got.

将上述命令中的路径修改为你获取的解释器路径。

http://www.lryc.cn/news/413574.html

相关文章:

  • 基于SpringBoot+Vue的校园便利平台(带1w+文档)
  • 串口应用编程-I.MX6U嵌入式Linux C应用编程学习笔记基于正点原子阿尔法开发板
  • Canvas实现截图
  • Python高性能计算:进程、线程、协程、并发、并行、同步、异步
  • kafka基本操作
  • JavaFX布局-Accordion
  • 【轨物方案】评估光伏组件发电性能一致性方案
  • 安全基础学习-keil调试汇编代码
  • Unity复制对象时让私有变量也被复制的简单方法
  • Flink 实时数仓(二)【DIM 层搭建】
  • 知识图谱开启了一个可以理解的人工智能未来
  • 借助Aspose.html控件, 将SVG 转PNG 的 C# 图像处理库
  • vs-2015安装教程
  • Stable Diffusion绘画 | 文生图设置详解—随机种子数(Seed)
  • 56、php实现N的阶乘末尾有多个0
  • 混合域注意力机制(空间+通道)
  • springboot长春旅游安全地图平台-计算机毕业设计源码90075
  • apex正则表达式匹配富文本字段内容,如何只匹配文本而忽略富文本符号
  • 空气净化器对去除宠物毛有效吗?小型猫毛空气净化器使用感受
  • vue的nextTick是下一次事件循环吗
  • 5.4.软件工程-系统设计
  • Apache Kylin与BI工具集成:数据可视化实战
  • 通过idea图形化界面就能push到github流程
  • C语言初阶(10)
  • Javaweb用过滤器写防跳墙功能和退出登录
  • 小试牛刀-Telebot区块链游戏机器人(TS升级)
  • MySQL:Prepared Statement 预处理语句
  • Java:Thread类以及线程状态
  • 如何通过前端表格控件实现自动化报表?
  • Upload-labs靶场Pass01-Pass21全解