python中pip下载报错

python中pip下载报错

有天不小心更新了pip,然后pip下载东西就会出现如下情况

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/pypi/simple/jupyter/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/pypi/simple/jupyter/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/pypi/simple/jupyter/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/pypi/simple/jupyter/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/pypi/simple/jupyter/

解决方案:

看到网上也有人提出用以下代码可以解决

pip install xx-i http://pypi.douban.com/simple --trusted-host pypi.douban.com

但是每次这样也挺麻烦,所以要找到pip的配置文件,从根本修改
我的pip文件在这个路径:C:\Users\用户名\AppData\Local\pip
(不同电脑可能不同,可以下载everything快速搜索)

原来的配置如下,会报错

[global]
index-url = https://repo.huaweicloud.com/repository/pypi/simple/
trusted-host = repo.huaweicloud.com
timeout = 120

修改后的配置如下,从根本上解决了问题

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

修改后再次pip install xx就不会报以上的错误了

你可能感兴趣的:(yolov5学习,python,pycharm,开发语言)