问题描述
PS C:\temp> python -m pip install --upgrade pip
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pip/
ERROR: Operation cancelled by user
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))) - skipping
解决方案
1. 临时解决方案
信任 pip install 时候加入可选命令 --trusted-host pypi.org
, 仅单次安装有效
信任官网链接: python -m pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org
临时使用镜像: pip install pillow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
建议使用下面的三种:
--trusted-host pypi.python.org
--trusted-host files.pythonhosted.org
--trusted-host pypi.org
2. 持久性解决方案
每次都输入那么长的指令是很难受的,下面说下windows电脑下解决方案
win+E
打开文件浏览器,在地址栏输入%APPDATA%
会打开roming文件夹,进入pip文件夹,如果没有就新建,新建pip.ini
文件,输入下面内容
[global]
timeout = 6000
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org