Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip install fails with “connection error" ssl problem

I am kind of new to Python and I started learning about packages and I tried to install some packages and update pip but I always get this error:

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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/

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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/

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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/

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: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/

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: unable to get local issuer certificate (_ssl.c:1108)'))': /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(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))

I tried to look online for a solution but anything I have tried by now has failed

Edit: solved it!

I have solved the problem and it was associated with my antivirus blocking pip. I have solved it by deleting my antivirus and everything works. Keep in mind that when I disable my antivirus and firewall, it didn't work and only worked when I deleted the antivirus completely.

I hope that if you have the same problem that will help you

like image 882
shaked maman Avatar asked May 24 '20 18:05

shaked maman


People also ask

What is SSL cert?

SSL certificates are what enable websites to move from HTTP to HTTPS, which is more secure. An SSL certificate is a data file hosted in a website's origin server. SSL certificates make SSL/TLS encryption possible, and they contain the website's public key and the website's identity, along with related information.

Can't connect to https URL because the SSL module is not available python Linux?

The error states that the SSL python module is not available; meaning you either don't have an appropriate ssl lib installed (probably not since you state the system python can pip install fine), or the python you built from source or otherwise installed doesn't include the ssl module.


2 Answers

Please try updating your pip using the trusted option:

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

To make this setting permanent you can create a pip.ini file in your user folder that contains:

[global]
trusted-host = files.pythonhosted.org
               

Please note that this is a more generic solution, pointing to trust the fils.pythonhosted.org host.
It is important to investigate and understand the root cause of the issue (wrong time / date, for example, can be one of the possible ones).

like image 187
Pitto Avatar answered Oct 12 '22 08:10

Pitto


In my case it was a clock misconfigured.

I fixed that following this tutorial: Network - NTP

Check if your system clock is correct:

timedatectl status
Local time: Fr 2018-02-23 08:47:13 UTC
                   Universal time: Fr 2018-02-23 08:47:13 UTC
                         RTC time: Fr 2018-02-23 08:47:13
                        Time zone: Etc/UTC (UTC, +0000)
        System clock synchronized: yes
 systemd-timesyncd.service active: yes
                  RTC in local TZ: no

If not, install chrony:

sudo apt install chrony

And start chronyd - the actual daemon to sync and serve via the NTP protocol

sudo chronyd
like image 1
Marcelo Gazzola Avatar answered Oct 12 '22 07:10

Marcelo Gazzola