Python pip install error [SSL: CERTIFICATE_VERIFY_FAILED]

Question:

I have been trying to figure this out for a while now and for some reason I get stuck with an ssl issue and have no idea what is going on.

Problem:
I have installed python2.7 and easy_install2.7, but when trying to install pip with easy_install2.7 I get the following error.

[root@cops-wc-01]# /usr/local/bin/easy_install-2.7 pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Download error on https://pypi.python.org/simple/pip/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) — Some packages may not be found!
Couldn’t find index page for ‘pip’ (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) — Some packages may not be found!
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse(‘pip’)

It is trying to download, but this SSL cert verification failure is preventing it.

Does anyone know a way around this, or a way to resolve it?

Sorry if it is a noob question 🙂

[root@cops-wc-01]# uname -a
Linux 2.6.32-504.30.3.el6.x86_64 #1 SMP Wed Jul 15 10:13:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@cops-wc-01]#

Centos 6

Asked By: jmg0880

||

Answers:

Most likely pip does not have the required CA certificates to validate that.

You can force pip to use openssl’s CAs to see if it helps.

Answered By: tstark81

I didn’t realize that there is a command “python -M ensurepip after 7.9. This fixed my issue.

Answered By: jmg0880
apt-get install ca-certificates

If you missed this package.

Answered By: Qi Luo

The easiest solution that worked for me:

  1. From https://pypi.python.org/pypi/pip, download ‘pip-8.1.2.tar.gz’
  2. Install it with pip, “pip install ./pip-8.1.2.tar.gz”
  3. On the ubuntu server, the new version pip may be installed in a different location. If checking version with ‘pip –version’, it’s still an older version one, like pip 1.5.6. To install a package with the new version pip, straightforwardly use the absolute path for convenience:

/home/tom/.local/bin/pip install ./gensim-0.13.1.tar.gz

Install dependencies one by one, errors like this below can be bypassed.

Download error on https://pypi.python.org/simple/pip/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) — Some packages may not be found!”

Answered By: Tom

On macbook put this line in ~/.bash_profile:

export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem

And forget about this error.

Of course, if you don’t have openssl – run brew install openssl. And don’t forget to do . .bash_profile after first edit of .bash_profile.

Answered By: Nikolay Fominyh

On my device (that runs nix),

$ date showed ...1969

so I had to set the date to a more recent time :

$ date -s "26 MAR 2017 13:16:00"

Then the SSL error was gone.

Answered By: Tom

I ran the following commands to resolve the issue:

$ curl https://bootstrap.pypa.io/get-pip.py >> get-pip.py
$ python get-pip.py

This upgraded pip to v9.0.3, and this version has no issues.

Answered By: simbawesley

Since this is currently the top hit on Google for this issue I thought I would share my solution. As weird as it is. I’m on CentOS 7, Python3.6 although I believe it doesn’t matter which Python version.

The SSLError / CERTIFICATE_VERIFY_FAILED was also happening for me when I ran a fresh copy of get-pip.py.

The solution was to run the install command with output piped to a file, so python get-pip.py &> output. I haven’t had the time to find out why not having a TTY affects the environment for the script.

Answered By: Tom Winch

YAS (Yet Another Solution)
I had the same issue.
Tried everything above.
My issue was fixed by upgrading pip and setuptools:

$ pip install -U pip setuptools

I also tried to add an entry in my ~/.pip/pip.conf file:

[global]
trusted=https://pypi.your.domain

Answered By: Franck

If you are running behind a web filter or firewall, please ensure SSL inspection/decryption is disabled or bypassed for the domain *.pythonhosted.org (or more specifically, files.pythonhosted.org). May also need to include pypi.org.

I’m running Python on an enterprise workstation and this has been the culprit in our environment across Windows and Linux hosts. Confirmed with our older system, a Broadcom ProxySG on prem web filter appliance, and later through Cisco’s Umbrella Cloud Gateway/SIG product.

Cheers

Answered By: Meticulous7Seven

I had pip install [SSL: CERTIFICATE_VERIFY_FAILED] errors caused by a corporate Secure Web Gateway (SWG) changing the remote SSL certs to ones signed by a non-standard CA. This was complicated by pip not passing CLI flags to subprocesses, so using CLI flags would work for simple pip installs, but fail if pip needed to build the module.

Fix was to add the SWG cert to a standard bundle (eg from https://curl.se/docs/caextract.html) and then tell pip to use the customised bundle via the PIP_CERT environment variable as per https://github.com/pypa/pip/issues/5502

ADD ../ssl/myCaCerts.pem /usr/local/share/myCaCerts.pem
ENV PIP_CERT=/usr/local/share/caCert.pem
RUN pip install <TheModule>
Answered By: Steve Campbell
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.