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

yipeiwu_com7年前Python基础

Python版本3.5.1,

pip install requests 之后依然提示

Python ImportError: No module named 'requests'

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

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

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

pip uninstall requests


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的安装目录下,执行:

pip install requests.

会出现如下的提示:

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'问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python设置matplotlib.plot的坐标轴刻度间隔以及刻度范围

Python设置matplotlib.plot的坐标轴刻度间隔以及刻度范围

一、用默认设置绘制折线图 import matplotlib.pyplot as plt x_values=list(range(11)) #x轴的数字是0到10这11个整数 y...

Python 实现毫秒级淘宝抢购脚本的示例代码

本篇文章主要介绍了Python 通过selenium实现毫秒级自动抢购的示例代码,通过扫码登录即可自动完成一系列操作,抢购时间精确至毫秒,可抢加购物车等待时间结算的,也可以抢聚划算的商品...

基于Python实现文件大小输出

基于Python实现文件大小输出

在数据库中存储时,使用 Bytes 更精确,可扩展性和灵活性都很高。 输出时,需要做一些适配。 1. 注意事项与测试代码 1.需要考虑 sizeInBytes 为 None 的场景。...

python语言基本语句用法总结

python语句与语法 1.python简单语句的基本介绍 >>> while True: #简单的while循环 ... reply = input('Ente...

python机器人运动范围问题的解答

机器人的运动范围Python实现: 问题:地上有个 m 行 n 列的方格。一个机器人从坐标(0,0)的格子开始移动,它每一次可以向左、右、上、下移动一格,但不能进入行坐标和列坐标的数位之...