这里写自定义目录标题
1. 问题记录
最近学习Python遇到一些问,在此记录一下
安装模块requests
pip install requests
出现了下面的报错
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))': /simple/requests/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))': /simple/requests/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))': /simple/requests/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))': /simple/requests/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))': /simple/requests/
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests
看报错日志感觉是连接它的 pypi 库下载官网有问题,使用默认的 pip 库下载地址安装本来就很慢。
我就试了试,改了个阿里云的镜像地址,然后就好了。
方式如下:
pip install requests -i https://mirrors.aliyun.com/pypi/simple/
结果如下
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting requests
Downloading https://mirrors.aliyun.com/pypi/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl (62 kB)
|████████████████████████████████| 62 kB 392 kB/s
Collecting charset-normalizer<4,>=2
Downloading https://mirrors.aliyun.com/pypi/packages/96/fc/0cae31c0f150cd1205a2a208079de865f69a8fd052a98856c40c99e36b3c/charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl (98 kB)
|████████████████████████████████| 98 kB 1.1 MB/s
Collecting certifi>=2017.4.17
Downloading https://mirrors.aliyun.com/pypi/packages/64/62/428ef076be88fa93716b576e4a01f919d25968913e817077a386fcbe4f42/certifi-2023.11.17-py3-none-any.whl (162 kB)
|████████████████████████████████| 162 kB 1.7 MB/s
Collecting idna<4,>=2.5
Downloading https://mirrors.aliyun.com/pypi/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 57 kB/s
Collecting urllib3<3,>=1.21.1
Downloading https://mirrors.aliyun.com/pypi/packages/d2/b2/b157855192a68541a91ba7b2bbcb91f1b4faa51f8bae38d8005c034be524/urllib3-2.0.7-py3-none-any.whl (124 kB)
|████████████████████████████████| 124 kB 1.6 MB/s
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2023.11.17 charset-normalizer-3.3.2 idna-3.6 requests-2.31.0 urllib3-2.0.7
下面附上国内的多次镜像地址
2. 国内常用镜像源汇总
- 清华镜像
https://pypi.tuna.tsinghua.edu.cn/simple
- 中科大镜像
https://pypi.mirrors.ustc.edu.cn/simple
- 豆瓣镜像
http://pypi.douban.com/simple/
- 阿里镜像
https://mirrors.aliyun.com/pypi/simple/
- 华中科大镜像
http://pypi.hustunique.com/
- 山东理工大学镜像
http://pypi.hustunique.com/
- 搜狐镜像
http://mirrors.sohu.com/Python/
- 百度镜像
https://mirror.baidu.com/pypi/simple