以前,“ requests”库在工作,但是我想做一个项目并安装一些库,并且库中包括“ requests == 2.22.0”。安装库之后,我发现在PyCharm上出现错误:
Traceback (most recent call last):
File "C:/Users/User/Desktop/python/projects/youtube downloader.py", line 5, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
当我尝试再次使用pip安装请求时,我不断遇到这些错误, 我也尝试卸载请求,然后重新安装:
C:\Users\User>pip3 install requests
Requirement already satisfied: requests in c:\users\muffin\anaconda3\lib\site-packages (2.21.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (1.24.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (2018.11.29)
C:\Users\User>pip install requests
Requirement already satisfied: requests in c:\users\muffin\anaconda3\lib\site-packages (2.21.0)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (3.0.4)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (1.24.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\User\appdata\roaming\python\python37\site-packages (from requests) (2018.11.29)
我注意到我有两个?我的计算机中安装了python,但是我从不知道该如何处理两个python(我将Ananconda用于Jupiter Notebook和PyCharm),并且我认为这可能是为什么pip无法按预期工作的问题。 。 或不。我很困惑。
++因此,我在Jupiter笔记本中发现,我可以毫无问题地导入请求库,所以我认为我需要在其他路径下下载该库。
有人可以帮忙吗? 提前非常感谢您。
答案 0 :(得分:2)
您尚未为PyCharm配置Python解释器。按照this tutorial进行操作,就可以了。我建议使用Anaconda并手动或在PyCharm中创建一个virtual environment。将requests
安装到该环境。