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:没有名为“请求"的模块,但它
基础教程推荐
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
