学python这么久了,安装的包也有很多了,如pygal,matplotlib,按理说,我应该很有经验,昨天要要用到requests,于是乎,我直接上手安装,可是什么喵的,不管用whl文件安装,还是解压tar文件安装 总是报错。(废话不多说)。
1.我安装的方法:
下载所需文件
https://pypi.python.org/pypi/requests
用whl文件安装,首先进去whl文件所在位置
C:\Users\xxxx>pushd D:\编程软件\requests
D:\编程软件\requests>
D:\编程软件\requests>pip install requests-2.23.0-py2.py3-none-any.whl
Processing d:\编程软件\requests\requests-2.23.0-py2.py3-none-any.whl
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/urllib3/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/urllib3/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/urllib3/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/urllib3/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/urllib3/
ERROR: Could not find a version that satisfies the requirement urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests==2.23.0) (from versions: none)
ERROR: No matching distribution found for urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests==2.23.0)
2.提示的问题所在
Could not find a version that satisfies the requirement urllib3
给我提示错误找不到urllib3的需求版本。。
No matching distribution found for urllib3
和urllib3找不到匹配的分布。emmm,小白表示看不懂这些专业术语
3.解决方法
反正过了好久我反应过来是不是因为python国内网站网络不稳定的问题,于是我便用了一个镜像。。
pip install 包的名字 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
上手
D:\编程软件\requests>pip install requests-2.23.0-py2.py3-none-any.whl -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
其他的包安装时如果出现上述问题,也可以使用这种方法
4.结果
果真马上就安装好了。
Looking in indexes: http://pypi.doubanio.com/simple/
Processing d:\编程软件\requests\requests-2.23.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17
Downloading http://pypi.doubanio.com/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156 kB)
|████████████████████████████████| 156 kB 1.3 MB/s
Collecting idna<3,>=2.5
Downloading http://pypi.doubanio.com/packages/89/e3/afebe61c546d18fb1709a61bee788254b40e736cff7271c7de5de2dc4128/idna-2.9-py2.py3-none-any.whl (58 kB)
|████████████████████████████████| 58 kB 975 kB/s
Collecting chardet<4,>=3.0.2
Downloading http://pypi.doubanio.com/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133 kB)
|████████████████████████████████| 133 kB 1.1 MB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Downloading http://pypi.doubanio.com/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 939 kB/s
Installing collected packages: certifi, idna, chardet, urllib3, requests
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.9 requests-2.23.0 urllib3-1.25.8