SSL Cert Errors on Windows 10 When Installing Python 3 PIP and Python Modules Resolution
Introduction
Recently ran into an issue when trying to install Python PIP using get-pip.py and Python modules using PIP. The error I was receiving was 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: unable to get local issuer certificate (_ssl.c:1056)’))’: /simple/pip/. After a bit of research found a workable solution to get PIP installed. But that was not the end of the issue as the same error happened when trying to install Python modules using the PIP application. Luckily the workaround for PIP was the same for the modules.
Resolution
The resolution was simple with the help of adding a few switches to the command line. By adding three hosts using the –trusted-host option we can eliminate the SSL errors.
The three hosts to add are:
- pypi.python.org
- files.pythonhosted.org
- pypi.org
Since PIP is already installed we will need to include the –upgrade parameter. So our complete command line should look like this:
python -m pip install –trusted-host pypi.python.org –trusted-host files.pythonhosted.org –trusted-host pypi.org –upgrade pip
C:\Python37> python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
Using the same –trusted-host we can install python modules. In this example we will install influxdb.
pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org influxdb
If you are using the requirements.txt file to install multiple modules you can do so using the similar command.
pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org -r C:\Utils\grafana\vmax_monitoring-master\requirements.txt
Hope this helps!
You saved my day.. even SO couldn’t get me the answer.. thanks man