Eliminates SSL error when PIP Install on Windows.

Error that occurred

(ptoe) D:\MyFile\arc\pyenv\ptoe>pip install pprint
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:1108)'))': /simple/pprint/
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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pprint/
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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pprint/
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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pprint/
WARNING: Retrying (Retry(total=0, 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:1108)'))': /simple/pprint/
Could not fetch URL https://pypi.org/simple/pprint/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pprint/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))) - skipping
ERROR: Could not find a version that satisfies the requirement pprint (from versions: none)
ERROR: No matching distribution found for pprint
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: unable to get local issuer certificate (_ssl.c:1108)'))) - skipping

There is an error in SSL authentication. I can't trust the connection destination, but I don't know what the cause is. It's a company PC, so it's scary to mess with network settings too much.

Solution

After googled, it seems OK if the connection destination is trusted with the pip option. (I'm worried that there are only MAC examples and few Windows examples.)

Use the "--trusted-host" option to authenticate the connected site only during installation. The following three are required. If it is not enough, the same error as above will occur.

 --trusted-host pypi.python.org
 --trusted-host files.pythonhosted.org
 --trusted-host pypi.org

Practice

1. Update PIP.

(ptoe) D:\MyFile\arc\pyenv\ptoe>python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/36/74/38c2410d688ac7b48afa07d413674afc1f903c1c1f854de51dc8eb2367a5/pip-20.2-py2.py3-none-any.whl (1.5MB)
     |████████████████████████████████| 1.5MB 3.3MB/s
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-20.2

The PIP upgrade has passed! !! (* ´ω ` *)

2. Installation of the library that was in error

(ptoe) D:\MyFile\arc\pyenv\ptoe>python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org pip pprint
Requirement already satisfied: pip in ![Comment 2020-08-04 155203.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/600163/6dea129d-3250-af0c-fff9-bb139a38391f.png)
d:\myfile\arc\pyenv\ptoe\lib\site-packages (20.2)
Collecting pprint
  Downloading pprint-0.1.tar.gz (860 bytes)
Using legacy 'setup.py install' for pprint, since package 'wheel' is not installed.
Installing collected packages: pprint
    Running setup.py install for pprint ... done
Successfully installed pprint-0.1

The library was installed successfully.

Persistence

It's a little bit to write and install 3 "--trusted-host" every time ... In that case, if you create and write pip.ini, you do not need to specify the --trusted-host option after that.

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

I didn't know where to put pip.ini on Windows, It was written in the official pip documentation.

#For user local
%APPDATA%\pip\pip.ini

#Global
C:\ProgramData\pip\pip.ini

#Virtual environment(venv)in the case of
%VIRTUAL_ENV%\pip.ini

Virtual environment storage image キャプチャ.PNG

reference

https://github.com/pypa/pip/issues/5448 https://pip.pypa.io/en/stable/user_guide/#configuration

Recommended Posts

Eliminates SSL error when PIP Install on Windows.
# Solution when pip install gives an error when using Anaconda on Windows 10
Pip install --ugrade pip fails on Windows
Install Python on Windows + pip + virtualenv
Install easy_install and pip on windows
SSL certificate related with pip install? Error
Install pip on Mavericks
Error with pip install
Install Anaconda on Windows 10
Install python on windows
Install pycuda on Windows10
Install Chainer 1.5.0 on Windows
Install pip / pip3 on Ubuntu
When pip install fails
Install ZIP version Python and pip on Windows 10
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
I got a UnicodeDecodeError when pip install on ubuntu
Install Numpy on virtualenv on Windows
Install watchdog on Windows + Python 3.3
Install Win-Kex (kali-linux) on Windows 10.
Install cvxpy on windows, Anaconda
When moss with pip install
Install Chainer 1.6 (GPU) on Windows 7.
[Python] [Chainer] [Windows] Install Chainer on Windows
I got an error when pip install pandas on Mac, so I dealt with it
Install Jupiter Notebook on Windows with pip in proxy environment
I got an error when pip install tweepy on macOS Sierra, so I dealt with it
Pip install (Windows) under Proxy environment
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Pytorch on Blender 2.90 python on Windows
How to install pycrypto on Windows
Install pip on CentOS7. Also iPython.
Mastering pip and wheel on windows
Install Python development environment on Windows 10
Install PyStan on Windows without Anaconda
How to install music 21 on windows
[Python Windows] pip install with Python version
Dealing with PermissionError [Error 1] for pip install -U pip on macOS Sierra
Error resolution when installing numba on macOS
Solution for pip install error [Python] [Mac]
In pip install clang: error: unknown argument:'-mno-fused-madd'
[Kivy] How to install Kivy on Windows [Python]
Install wsl2 and master linux on windows
I got an SSL related error with pip install, so I solved it
Install Python package management tool pip (Windows)
scipy stumbles with pip install on python 2.7.8
How to install richzhang / colorization on Windows 10
Install python on xserver to use pip
Error, warning when using TensorFlow on Mac
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
Linux "Install on / dev / sda" error resolution
[OSX] [pyenv] What to do when an SSL error occurs in pip
fatal error: Python.h: no such files or directories when pip3 install psutil
Let's install box2d-py with Windows 10 environment pip
Install openstack client from pip so you don't get an error on CentOS7
Workaround if you get an error when trying to install PySide with pip
Error when installing a module with Python pip
I can't install Dask with pip on Ubuntu
Install and run Python3.5 + NumPy + SciPy on Windows 10
Install Python3, numpy, pandas, matplotlib, etc. on Windows