问题描述:

在终端pip第三方包时安装失败且出现提示语句:
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))

原因分析:

pip命令访问国外镜像源时连接超时

解决方法:

将pip的访问源更改为国内镜像源即可。
1、暂时访问
输入如下安装命令:
pip install [模块] -i https://pypi.douban.com/simple –trusted-host pypi.douban.com
例:pip install numpy -i https://pypi.douban.com/simple –trusted-host pypi.douban.com
其中:
https://pypi.douban.com/simple表示pip即将访问的某国内镜像源
trusted-host pypi.douban.com表示信任该源
2、永久访问(Windows)
win+r打开命令窗口,输入%HOMEPATH%进入用户默认路径

创建一个新的文件夹 pip,并在该目录下创建配置文件pip.ini,右键记事本打开将内容修改如下:

[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com

至此,修改完毕。

其他

1、其他操作系统下的永久修改镜像地址的方法参考文章:http://www.manongjc.com/detail/16-rdlxozmigggocep.html
2、国内其他镜像源:
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple

本文地址:https://blog.csdn.net/qq_42725497/article/details/110940883