Python Install 报错”‘SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED]

Problem Description

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

solution

1. Temporary solution

Add optional commands when trusting pip install --trusted-host pypi.org, only valid for a single installation

Trust official website link:python -m pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org

Temporarily use the mirror:pip install pillow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

The following three are recommended:
--trusted-host pypi.python.org
--trusted-host files.pythonhosted.org
--trusted-host pypi.org

2. Persistent solutions

It is uncomfortable to input such a long command every time. Let’s talk about the solution under windows computer.
win+EOpen the file browser, enter in the address bar, %APPDATA%it will open the roming folder, enter the pip folder, if not, create a new one, create a new pip.inifile, enter The following content

[global]
timeout = 6000
index-url=http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org

Guess you like

Origin blog.csdn.net/qq_33704787/article/details/129493769