问题:在使用python时,使用pip命令安装某包(比如:pip install flask-cors),出现了错误信息
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/flask-cors/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/flask-cors/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/flask-cors/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/flask-cors/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/flask-cors/
ERROR: Could not find a version that satisfies the requirement flask-cors (from versions: none)
ERROR: No matching distribution found for flask-cors
解决方法:出现该错误信息是因为pip源链接证书验证失败,将pip源调整为国内的的源就行
永久修改pip源,可操作如下:
windows:
①找到系统盘下:C:\C:\Users\用户名\AppData\Roaming
②查看在Roaming文件夹下有没有一个pip文件夹,如果没有创建一个
③进入pip文件夹,创建一个pip.ini文件
④打开pip.ini文件,写入
[global]
timeout = 60000 #设置超时,单位:s
index-url = http://mirrors.aliyun.com/pypi/simple #指定优先下载源
[install]
trusted-host = mirrors.aliyun.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/
注:目前豆瓣源下载时也会出现证书验证失败的问题,更换其他源即可
pip更新命令:pip install --upgrade pip