Solve the problem of SSLError during pip installation

Keywords: pip Windows SSL

The reason for this problem is that the certificate of the installation source is not trusted. You can change the configuration file of pip to solve this problem:
Where is the profile first to change it? Read the source code of pip:
Here is the pip source code

if WINDOWS:
    bin_py = os.path.join(sys.prefix, 'Scripts')
    bin_user = os.path.join(user_site, 'Scripts')
    # buildout uses 'bin' on Windows too?
    if not os.path.exists(bin_py):
        bin_py = os.path.join(sys.prefix, 'bin')
        bin_user = os.path.join(user_site, 'bin')

    config_basename = 'pip.ini'

    legacy_storage_dir = os.path.join(user_dir, 'pip')
    legacy_config_file = os.path.join(
        legacy_storage_dir,
        config_basename,
    )
else:
    bin_py = os.path.join(sys.prefix, 'bin')
    bin_user = os.path.join(user_site, 'bin')

    config_basename = 'pip.conf'

    legacy_storage_dir = os.path.join(user_dir, '.pip')
    legacy_config_file = os.path.join(
        legacy_storage_dir,
        config_basename,
    )
    # Forcing to use /usr/local/bin for standard macOS framework installs
    # Also log to ~/Library/Logs/ for use with the Console.app log viewer
    if sys.platform[:6] == 'darwin' and sys.prefix[:16] == '/System/Library/':
        bin_py = '/usr/local/bin'

Can be found
The path under windows is: [user folder] / pip/pip.ini
Other systems are: [user folder] / pip/pip.conf

I am in the windows system, and then enter user > administrator

No PIP folder found. It doesn't matter. We can create a new folder by ourselves named pip

And create the pip.ini file under the PIP folder

Open with notepad and enter the following configuration information

[global]  
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
disable-pip-version-check = true
timeout = 120  

[list]
format = columns

Index URL is the Douban source set here
Trusted host means to trust this address (which eliminates ssl validation)
Disable PIP version check = true set not to check version

format = columns here is the output style when using the pip list command. Enter pip config list
Effect:

Seeing this effect, it proves that the configuration file has taken effect.

Posted by mote on Sat, 30 Nov 2019 09:39:46 -0800