Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSLError installing with pip

I'm trying to install Django on a Windows 10 system.

Whatever I try to install with pip on cmd, I get these errors:

Collecting django
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))) - skipping
  Could not find a version that satisfies the requirement django (from versions: )
No matching distribution found for django
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: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))) - skipping

I've tried a lot of things from other questions but none is working.

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

pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org django
like image 273
yannm Avatar asked Jun 17 '19 09:06

yannm


People also ask

Where does pip Look for certificates?

Starting with v1. 3, pip provides SSL certificate verification over HTTP, to prevent man-in-the-middle attacks against PyPI downloads. This does not use the system certificate store but instead uses a bundled CA certificate store.

How do I disable pip SSL verification?

In Python use verify=False for requests. get (see: SSL Cert Verification). Use --proxy <proxy> to avoid certificate checks.


Video Answer


3 Answers

Setting up my proxy correctly fixed this for me as well. The problem was that I used the https protocol for my HTTPS_PROXY and https_proxy environment variables.

Use:

HTTPS_PROXY="http://username:[email protected]:8080"
https_proxy="http://username:[email protected]:8080"

Do not use:

HTTPS_PROXY="https://username:[email protected]:8080"
https_proxy="https://username:[email protected]:8080"
like image 106
Roy van Santen Avatar answered Sep 23 '22 12:09

Roy van Santen


My pip was working fine (Windows 7 and Python 3.8.6) until I upgraded pip from version 20.2.1 to 20.3.1, after which I also got the error:

SSL: WRONG_VERSION_NUMBER error.

This is reproducible. I uninstalled and reinstalled several times to confirm.

Solution (well, workaround): don't upgrade pip to 20.3.1.

Note: pip 20.3.1 works fine in my Windows 7/Python 3.9.1 environment.

like image 37
Mark Avatar answered Sep 22 '22 12:09

Mark


I asked a colleague who automatically knew what to do. I just had to set the proxy variables:

set https_proxy=http://username:[email protected]:8080
set http_proxy=http://username:[email protected]:8080

and it works.

like image 44
yannm Avatar answered Sep 25 '22 12:09

yannm