2

I am trying to install PIP using python get-pip.py and since I am behind a corporate firewall, the installation keeps failing.

 $ python get-pip.py
Collecting pip
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
  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(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) - skipping
  Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
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(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) - skipping

Is there a workaround for this? Is there a way I can turn off the verification?

I have also tried curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py

 $ curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Can I download the certificate for verification/turn verification off? Really stuck with this!

Brr Switch
  • 974
  • 1
  • 9
  • 21
  • Possible duplicate of [pip install fails with "connection error: \[SSL: CERTIFICATE\_VERIFY\_FAILED\] certificate verify failed (\_ssl.c:598)"](https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi) – Adil B Jun 05 '18 at 13:31
  • do you have a proxy credentials – Hari Jun 05 '18 at 13:42
  • 1
    use `pip install packagename --proxy :` – Surya Tej Jun 05 '18 at 13:47
  • @Hari I dont have any! – Brr Switch Jun 05 '18 at 13:49
  • @SuryaTej Have you read my question properly? I am having issues with installing pip itself – Brr Switch Jun 05 '18 at 13:50
  • So you mean to say, when you install the Python from a msi file, you don't find the pip exe inside the \PythonXX\Scripts folder? – Surya Tej Jun 05 '18 at 14:00
  • @SuryaTej no! Please read the question posted above. I'm unable to install pip! – Brr Switch Jun 05 '18 at 14:08
  • @SuryaTej I can see pip executable in the scripts folder – Brr Switch Jun 05 '18 at 17:06
  • Just wanted to know, if pip executable is already present, why do you wanna install it again? just set the path till scripts folder in your environment path variable and you should be good to use pip to install packages – Surya Tej Jun 06 '18 at 07:18

2 Answers2

1

I had this problem, the error message was a bit different but it was the same root cause. The firewall was preventing pip from making an internet connection.

To install a package in this scenario you can download the pip package and run pip without making an internet connection.

For example for matplotlib you can download the package from

https://pypi.org/project/matplotlib/#files

You want to download the wheel file (.whl)

There are quite a few downloads for different operating system and python version combinations. For Python 3.10 on windows I needed to download the file:

matplotlib-3.5.1-cp310-cp310-win_amd64.whl

With the file downloaded I ran the following command from the directory the .whl file is in:

python -m pip install matplotlib-3.5.1-cp310-cp310-win_amd64.whl --no-index --trusted-host=None --find-links .

This installed matplotlib without making an internet connection.

Aidan
  • 1,550
  • 1
  • 13
  • 20
0

In Linux:

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install python-pip

In Windows:

Take a look here

Paulo Fabrício
  • 319
  • 3
  • 17