'Unable to install packages or use certain libraries due to SSLCertVerificationError

I work behind a corporate VPN and attempting to install any packages in Python using pip or running an requests statements end in a similar error:

There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443)

I understand that there are several workarounds available, such as setting the --trusted-host parameters when running pip install. However, when using libraries that use requests, I am not able to avoid the error.

For example, I was able to install geocoder, but the error appears again because geocoder uses requests to retrieve the JSON data from Google.

Is there a permanent solution to this? I have also tried the suggested solution of adding the trusted hosts to my %APPDATA%\pip\pip.ini without success.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source