0

I am trying to install numpy package using pip while working with pyenv (global version 3.8.6).

Command:

pip install numpy

Output:

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: self signed certificate in certificate chain (_ssl.c:1124)'))': /simple/numpy/
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: self signed certificate in certificate chain (_ssl.c:1124)'))': /simple/numpy/
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: self signed certificate in certificate chain (_ssl.c:1124)'))': /simple/numpy/
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: self signed certificate in certificate chain (_ssl.c:1124)'))': /simple/numpy/
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: self signed certificate in certificate chain (_ssl.c:1124)'))': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1124)'))) - skipping
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy

What I tried to fix this issue:

  • Reinstalling openssl using brew reinstall openssl
  • Reinstalling pyenv using brew reinstall pyenv
  • Reinstalling pyenv-virtualenv using brew reinstall pyenv-virtualenv

When I try to disable pyenv by removing eval "$(pyenv init -)" and eval "$(pyenv virtualenv-init -)" from the ~/.bash_profile, it works fine as it uses the system Python version.

A short term solution is to add --trusted-host pypi.org flag, but I am not sure why it is not working without the flag.

Please help!

  • I am using MacOs BigSur and pyenv is not working fine. later found new version of mac is not updating the openssl anymore. So, I used brew to install openssl@1.1. configured path, pkgconfig, cnames and all. Now I can run applications but unable to install any package via private nexus repository. Also, unable to verify ssl certs for wss client like paho-mqtt. This looks like issue with openssl in my MacOs. Still figuring out... – bh4r4th Mar 16 '21 at 04:00
  • You should reinstall Xcode command line tools that contains Python. https://stackoverflow.com/a/68247505/4067700 – Victor Kushnerov Jul 05 '21 at 08:37

1 Answers1

0

As seen here, in previous versions of Python, Apple provided the OpenSSL packages, but they no longer do.

For a temporary fix, add pypi.org as a trusted host (pythonhosted.org actually hosts the files, but they are downloaded from pypi hence why they are also added to the trusted hosts) when using pip:

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools

For a more permanent fix install certifi and Scrapy:

pip install certifi
pip install Scrapy

Similar question 1
Similar question 2

DapperDuck
  • 2,728
  • 1
  • 9
  • 21
  • This is not useful, my question is more on why I am getting an SSL error when I am trying not to put --trusted-host. It works fine with --trusted-host flag as I mentioned above. – Himanshu Malhotra Jan 07 '21 at 13:55
  • @HimanshuMalhotra I have updated myanswer to explain why this problem occurs and why you have to put the flag. – DapperDuck Jan 07 '21 at 15:38