ModuleNotFoundError: No module named #39;requests#39; but it#39;s installed?(ModuleNotFoundError:没有名为“请求的模块,但它已安装?)
问题描述
我在 CMD 中使用了命令 pip install requests 并成功安装了请求模块,但是当我尝试将其导入 PyCharm 中的文件时,它会抛出
I used the command pip install requests in CMD and successfully installed the requests module, but when I try and import it to my file in PyCharm it throws
"ModuleNotFoundError: 没有名为请求"的模块
"ModuleNotFoundError: No module named 'requests'
我看到了一些关于这个问题的其他帖子,但没有找到可行的解决方案.
I saw a couple other posts about this issue but did not find a working solution.
作为旁注,我已经在我的 Python IDLE 中成功运行了这段代码,所以我认为这不是代码问题,而只是我的 PyCharm 设置的问题.
As a side note I have successfully run this code in my Python IDLE so I presume this is not a code issue, and just an issue with my PyCharm settings.
Traceback (most recent call last):
File "C:/Users/danie/PycharmProjects/Web_Scraping_Project/Web_Scraper.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Process finished with exit code 1
推荐答案
你必须激活虚拟环境.
source venv/bin/activate
pip install requests
或者您可以从 PyCharm GUI 添加库.有一个+"在编辑解释器的设置中,点击在上面搜索 requests 库.
Or you can add the library, from the PyCharm GUI.
There is a "+" on the edit interpreter in settings in the, click on it and search for the requests library.
这篇关于ModuleNotFoundError:没有名为“请求"的模块,但它已安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ModuleNotFoundError:没有名为“请求"的模块,但它
基础教程推荐
- 修改列表中的数据帧不起作用 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 求两个直方图的卷积 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 包装空间模型 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
