问题描述
在linux终端里pip install一般的包,发现timed out
具体如下:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('timed out'))': /simple/six/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('timed out'))': /simple/six/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('timed out'))': /simple/six/
问题解决
网上查找方式,一般都是替换源进行下载。下面以豆瓣源下载为例:
临时解决
pip install packagename -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
永久解决
修改~/.pip/pip.conf文件。若没有此文件,应该在~/.config/pip/pip.conf路径下
[global]
trusted-host = pypi.douban.com
index-url = http://pypi.douban.com/simple