脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - 解决已经安装requests,却依然提示No module named requests问题

解决已经安装requests,却依然提示No module named requests问题

2021-02-22 00:10弈心逐梦 Python

今天小编就为大家分享一篇解决已经安装requests,却依然提示No module named 'requests'问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

Python版本3.5.1,

pip install requests 之后依然提示

Python ImportError: No module named 'requests'

经过文件搜索和提示,发现是因为安装目录不正确。

一定要切到Python的主目录下安装requests。

如果提示已经安装,那原因是安装的路径不正确,需要先卸载。找到现在的安装目录(会提示),在CMD窗口切过去,执行:

pip uninstall requests

?
1
2
3
4
5
6
C:\Users\Administrator>pip uninstall requests
Uninstalling requests-2.14.2:
 c:\programdata\anaconda3\lib\site-packages\requests
 c:\programdata\anaconda3\lib\site-packages\requests-2.14.2-py3.6.egg-info
Proceed (y/n)? y
 Successfully uninstalled requests-2.14.2

然后,将目录切到Python的安装目录下,执行:

?
1
pip install requests.

会出现如下的提示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Collecting requests
 Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connec
tion broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.conne
ction.VerifiedHTTPSConnection object at 0x036C1850>: Failed to establish a new c
onnection: [Errno 11003] getaddrinfo failed',)': /simple/requests/
 Downloading requests-2.18.3-py2.py3-none-any.whl (88kB)
 46% |██████████████▉ | 40kB 251kB/s eta 0:00:
 57% |██████████████████▌ | 51kB 268kB/s eta 0
 69% |██████████████████████▏ | 61kB 315kB/s e
 80% |█████████████████████████▉ | 71kB 341kB/
 92% |█████████████████████████████▋ | 81kB 38
 100% |████████████████████████████████| 92kB
 359kB/s
 
Collecting urllib3<1.23,>=1.21.1 (from requests)
 Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
 38% |████████████▍ | 51kB 965kB/s eta 0:00:01
 46% |██████████████▉ | 61kB 1.1MB/s eta 0:00:
 54% |█████████████████▍ | 71kB 1.1MB/s eta 0:
 61% |███████████████████▉ | 81kB 1.0MB/s eta
 69% |██████████████████████▎ | 92kB 1.1MB/s e
 77% |████████████████████████▊ | 102kB 1.1MB/
 85% |███████████████████████████▎ | 112kB 1.0

至此,问题解决。

以上这篇解决已经安装requests,却依然提示No module named 'requests'问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/dreamstone_xiaoqw/article/details/77042485

延伸 · 阅读

精彩推荐