When using pip behind a corporate environment, I got the following error.
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:1076)'))': /simple/requests/
The error occurred because all internet access require to go through my corporate outbound HTTP proxy server. In this tutorial, I will show you how you can configure pip to connect through the proxy server.
Get proxy settings
Before you set the proxy settings, you first need to know what they are. You either ask your system administrator or get the information from Internet Explorer. It is much easier to get these information from Internet Explorer than from the system administrator. Here is how to get the information from Internet Explorer.
- Open the Internet options of the Internet Explorer.
- Navigate to the Connections tab.
- At the bottom right, click on the LAN settings button.
- The value in the Address input field is the proxy settings that you need. What is before the colon(:) is the server address. What is after the colon(:) is the port number.
Use --proxy command-line
With the proxy settings information, you can use the --proxy
command-line option to specify a proxy in the form [user:passwd@]proxy.server:port
.
For example, if you want to install requests package. You can do it using the following command line.
pip --proxy http://some-proxy-ip.com:8087 install requests
Use config file
Instead of typing out the --proxy
option every time you run pip, you can set the proxy settings in the pip configuration file. The location
of this file vary slightly for different platforms.
- For MS Windows, the configuration is located at
%APPDATA%\pip\pip.ini
. - For MacOS, the configuration is located at
$HOME/Library/Application Support/pip/pip.conf
. - For Unix, the configuration is located at
$HOME/.config/pip/pip.conf
.
If path doesn't exist, create it.
In your config file, set the followings.
[global] proxy = http://some-proxy-ip.com:8087