26

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yannm
  • 491
  • 1
  • 4
  • 11
  • 1
    your firewall is not allowing pip to connect to internet, so allow pip from the windows firewall and it will work – Exprator Jun 17 '19 at 09:13
  • make sure that you have strong internet connection and allow firewall to connect to pip **refer this** https://github.com/pypa/pip/issues/6152 – rahul.m Jun 17 '19 at 09:15
  • @Exprator The internet connection isn't a problem so it's probably the company's firewall and I don't think I can allow it myself. Is there another way to install django? – yannm Jun 17 '19 at 09:36
  • 1
    Doing a trace route might shed some light on where it is being block. From `cmd`, try `tracert pypi.python.org`. If you see an address with `*` displayed, that means it can't reach that hop point. – FlipperPA Jun 17 '19 at 10:52
  • @FlipperPA I have indeed * displayed so I guess it can't reach ....This is probably because of the company's firewall and I tried some commands with proxy but nothing seems to works – yannm Jun 17 '19 at 11:53
  • If you're using a VPN, it may be best to disable it first. This is what worked for me. – NelsonGon Dec 21 '20 at 05:38

6 Answers6

56

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:password@proxy.example.com:8080"
https_proxy="http://username:password@proxy.example.com:8080"

Do not use:

HTTPS_PROXY="https://username:password@proxy.example.com:8080"
https_proxy="https://username:password@proxy.example.com:8080"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Roy van Santen
  • 2,361
  • 3
  • 10
  • 11
12

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mark
  • 374
  • 4
  • 9
  • Probably the only valid answer! –  Jan 14 '21 at 12:41
  • 1
    I found by trial and error that 20.2.4 was the highest version that works for me with python 3.7.9 – James Feb 04 '21 at 15:02
  • I also ran into this issue with a fresh install of Python 3.9.1 on Win10 and upgrade to pip 21.0.1. Solution was to reinstall Python and stay with pip on version 20.2.3. We have a SSL Interception Proxy and i tried to set global.cert which seems not to be used by pip 21.0.1. I filed an issue: https://github.com/pypa/pip/issues/9614 – Martin Feb 16 '21 at 16:29
  • @LuciusSilanus How you solve your problem, may you share ? – ugurtosun Mar 31 '21 at 11:03
  • @UğurGürkanTosun I had to download a wheel for pip 20.2.4 and install it from the wheel file (https://stackoverflow.com/a/28002930/4871972) – Lucius Silanus Apr 03 '21 at 21:44
11

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

set https_proxy=http://username:password@proxy.example.com:8080
set http_proxy=http://username:password@proxy.example.com:8080

and it works.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yannm
  • 491
  • 1
  • 4
  • 11
  • 1
    Setting in what context? In some batch file? Directly on the command line before some install steps? Something else? Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/56649266/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Feb 04 '22 at 18:06
4

Check your proxy setting. You can use this command

pip install <package> --trusted-host pypi.org --trusted-host files.pythonhosted.org --proxy="<IP>:<port>"
Rin Nguyen
  • 405
  • 4
  • 11
  • I still have this error : " Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to 192.168.0.254 timed out. (connect timeout=15)')': /simple/django/" – yannm Jun 17 '19 at 11:55
  • 2
    This command works fine `pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org --proxy="http://:@:"` – NaveenKumar Namachivayam Dec 10 '19 at 19:33
  • Worked for me as well. Thanks!! – Ashlin Karkada Apr 10 '20 at 05:17
0

For me it was the system proxy. The trusted-host flag, to my knowledge, is used when pip wants to query an insecure http index and pip defaults to query only SSL secured indexes.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
pouya
  • 3,400
  • 6
  • 38
  • 53
0

Try finding and removing OpenSSL (OS level installation), if it's installed on your system.

In my case, I installed OpenSSL on Windows 10 (for some other development tasks) long time ago and forgot about it, which was the main culprit. I uninstalled it, and it solved the issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
tayyab
  • 78
  • 1
  • 6