使用PIP 安装的时候一直提示下面的错误,安装不能成功:

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000238CE8677B8>, 'Connection to pypi.org timed out. (connect timeout=15)')': 

经过查询,是网络问题,有两种解决方法

1.临时解决方法:

pip install <包名> -i http://pypi.douban.com/simple --trusted-host pypi.douban.com 或者

pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com  <包名>

其中“pypi.douban.com”为更改的源。

2.使用文件方式修改

Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹),内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn:

windows下,直接在user目录中使用的账户“xxx”下面创建一个pip目录,如:C:\Users\xxx\pip,新建文件pip.ini。内容如下

[global]

index-url = http://pypi.douban.com/simple

trusted-host = pypi.douban.com

 

附国内的更新源:
阿里云 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/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/ 

 

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐