88

pip install <package name> is failing for every package for me. This is what I get:

Could not find a version that satisfies the requirement <package-name
(from versions: )
No matching distribution found for <package-name>

I saw similar questions on Stack Overflow, but they don't seem to be fully related to this one.

Also, this post suggests that this might happen if PyPI is down or my IP address is blacklisted. It seems both are not true for my case.

pip shows up-to-date on running pip install --upgrade pip.

Anupam
  • 12,420
  • 12
  • 51
  • 82
  • can you provide an example, of how you do `pip install ` with an actual package name, or just post your `requirements.txt`? thanks – N. Ivanov Apr 10 '18 at 07:45
  • 2
    I have tried many. Even `pip install django` doesnt work. It always worked earlier. – Anupam Apr 10 '18 at 07:46
  • have you tried updating pip version? which python and python-pip versions are you using? are you sure your machine is connected to the internet? – N. Ivanov Apr 10 '18 at 07:47
  • 1
    What's the output produced when you use `pip install -vvv `? – Martijn Pieters Apr 10 '18 at 07:48
  • 1
    @N. Ivanaov yes the machine is connected (since I am able to create this post). Yes I tried upgrading pip and its already up-to-date. – Anupam Apr 10 '18 at 07:49
  • Would really appreciate downvotes supported with comments please. This is a real problem. I am a Django developer and have been using pip for quite sometime! – Anupam Apr 10 '18 at 07:50
  • @MartijnPieters: Thanks, that helps in moving forward atleast. Looks like something changed on the security protocol required by PyPi. This is what I get: `Could not fetch URL https://pypi.python.org/simple/django/: 403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/simple/django/ - skipping Could not find a version that satisfies the requirement django (from versions: )` – Anupam Apr 10 '18 at 07:53

2 Answers2

156

Upgrade pip as follows:

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

Note: You may need to use sudo python above if not in a virtual environment.

What's happening:

Python.org sites are stopping support for TLS versions 1.0 and 1.1. This means that Mac OS X version 10.12 (Sierra) or older will not be able to use pip unless they upgrade pip as above.

(Note that upgrading pip via pip install --upgrade pip will also not upgrade it correctly. It is a chicken-and-egg issue)

This thread explains it (thanks to this Twitter post):

Mac users who use pip and PyPI:

If you are running macOS/OS X version 10.12 or older, then you ought to upgrade to the latest pip (9.0.3) to connect to the Python Package Index securely:

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

and we recommend you do that by April 8th.

Pip 9.0.3 supports TLSv1.2 when running under system Python on macOS < 10.13. Official release notes: https://pip.pypa.io/en/stable/news/

Also, the Python status page:

Completed - The rolling brownouts are finished, and TLSv1.0 and TLSv1.1 have been disabled. Apr 11, 15:37 UTC

Update - The rolling brownouts have been upgraded to a blackout, TLSv1.0 and TLSv1.1 will be rejected with a HTTP 403 at all times. Apr 8, 15:49 UTC

Lastly, to avoid other install errors, make sure you also upgrade setuptools after doing the above:

pip install --upgrade setuptools
Anupam
  • 12,420
  • 12
  • 51
  • 82
  • Thank you, worked perfect for me on MacOS getting error installing any package: `Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skipping` – emmdee Apr 13 '18 at 16:51
  • Worked on mac 10.11.6 – André Duarte Apr 24 '18 at 19:43
  • 6
    Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/setuptools-1.3.1-py2.7.egg' Consider using the `--user` option or check the permissions. .... Should I add the --user option? – user805981 Apr 27 '18 at 13:26
  • @user805981 seems like a separate issue. Would you like to to start a separate post ? – Anupam Apr 27 '18 at 15:17
  • 9
    In case you face any permission issues, use : curl https://bootstrap.pypa.io/get-pip.py | sudo python – Abhishek Lodha Apr 30 '18 at 09:48
  • @AbhishekLodha : doesnt work for me. i am getting "Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-7.1.2.dist-info/DESCRIPTION.rst' – Anuj Gupta May 13 '18 at 16:06
  • @AnujGupta you need to give permissions to the python folder. sudo chown -R $USER /Library/Python/2.7 – Abhishek Lodha May 16 '18 at 06:52
  • @AbhishekLodha: I did this, yet I was getting this error. that's why i raised it here – Anuj Gupta May 16 '18 at 10:34
  • This saved a lot of typing for me on my url box... – NightOwl19 Jul 16 '18 at 19:41
  • 11
    (using MacOS) In my case helped only: `curl https://bootstrap.pypa.io/get-pip.py | sudo python` – Lord Nighton Jul 27 '18 at 03:39
  • 6
    not working anymore? Wondering how everyone can accept this answer – Oliver Schneider Jul 27 '18 at 08:20
  • @OliverSchneider it still works. Do you see an error when you run it? – Anupam Jul 28 '18 at 01:49
  • @Anupam, thx, had to update Python to 3.7 too – Oliver Schneider Jul 28 '18 at 05:15
  • thank you very much ,it works for me in my mac – wolfog Aug 28 '18 at 15:50
  • 1
    I'm on Linux and these instructions didn't help – Csaba Toth Sep 06 '18 at 05:38
  • @CsabaToth what distribution of Linux are you on? Alternatively, you could use `apt` or `yum` or another command to install `pip` depending on your distribution – Anupam Sep 06 '18 at 05:49
  • @Anupam Devuan ascii (It's a Debian which avoids systemd). The system `python-pip` is 9.0, but I upgraded it out of band several times and pip --version returns 18. – Csaba Toth Sep 06 '18 at 05:52
  • Ok - and what version of Python? `python-pip` is for Python 2 and `python3-pip` is for Python 3. [This list](https://www.tecmint.com/install-pip-in-linux/) maybe be helpful – Anupam Sep 06 '18 at 06:22
  • Specifically I'm trying to install `python-apns` which is compatible both with Python 2.7 and Python 3. My source is Python 2.7 and I'm working in a Python virtual environment. I tried `python2.7 -m pip install python-apns` and `python3 -m pip install python-apns` both inside the virtualenv and outside and all 4 tries result the same `(from versions: )` so something is brain dead. Do you think it can be Linux distribution related or rather some clashes of Python versions? – Csaba Toth Sep 06 '18 at 15:40
  • 1
    Nevermind... I realized I was using wring package name – Csaba Toth Sep 06 '18 at 16:14
  • macOS Sierra 10.12.6: Only command which worked for me (given permissions on .../Caches/pip) was: $ sudo -H curl https://bootstrap.pypa.io/get-pip.py | sudo -H python – DrLou Sep 14 '18 at 15:18
  • I am using windows and facing a similar issue, I am using python 3.6.8 and pip version 18.1 – Anchal Sarraf Apr 11 '19 at 06:52
  • 1
    On Windows 10, I had the python 3.7.1 32bit installed and had manually upgraded the pip, using pip install --upgrade pip. This meant my pip was upgraded to version 19.1. I uninstalled Python (and pip), and reinstalled Python 3.7 using the amd64 executable installer. I've avoided upgrading pip, for now, and it's working fine. Hope this helps someone else. – Victor Romeo May 30 '19 at 01:14
  • this worked for me curl https://bootstrap.pypa.io/get-pip.py | python as per the answer states – danivicario Jul 02 '19 at 21:31
  • Using this had another problem with being unable to find pip, led me to this issue here: https://stackoverflow.com/questions/16237490/i-screwed-up-the-system-version-of-python-pip-on-ubuntu-12-10 – RegressForward Nov 24 '19 at 02:45
  • If your problem still persist even though you have latest pip installed, probably try to upgrade these other packages too: `pip install pyOpenSSL backports.ssl requests` – Ilyas Foo Dec 11 '19 at 15:24
  • I got the following error "could not find a version that satisfies the requirement rsa>=3.1.4" when executing this command "pip install gspread oauth2client" and its been resolved after executing "pip install --upgrade setuptools" – Wathsala Karunathilake Apr 15 '20 at 03:45
  • For me this *downgraded* me to pip 7.1.2 for some reason... – Ben Farmer Nov 25 '20 at 23:58
  • 1
    This nows points to python3 syntax script, so you might need to do this: `curl https://bootstrap.pypa.io/get-pip.py | python3` – Shoham Feb 03 '21 at 16:19
  • `curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.` – Max Riley Feb 13 '21 at 21:51
9

Support for TLS 1.0 and 1.1 was dropped for PyPI. If your system does not use a more recent version, it could explain your error.

Could you try reinstalling pip system-wide, to update your system dependencies to a newer version of TLS?

This seems to be related to Unable to install Python libraries

See Dominique Barton's answer:

Apparently pip is trying to access PyPI via HTTPS (which is encrypted and fine), but with an old (insecure) SSL version. Your system seems to be out of date. It might help if you update your packages.

On Debian-based systems I'd try:

apt-get update && apt-get upgrade python-pip

On Red Hat Linux-based systems:

yum update python-pip # (or python2-pip, at least on Red Hat Linux 7)

On Mac:

sudo easy_install -U pip

You can also try to update openssl separately.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Guybrush
  • 1,957
  • 1
  • 8
  • 16
  • Thanks for the tip but `sudo easy_install -U pip` didnt work for me on Mac OSX 10.11.X. `Searching for pip Reading https://pypi.python.org/simple/pip/ 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/ No local packages or download links found for pip error: Could not find suitable distribution for Requirement.parse('pip')` – Anupam Apr 10 '18 at 11:05
  • I'm sorry, I'm not an OSX user, so I can't help you on that. Please have a look at @Anupam's answer for instructions on how to (re-)install pip on OSX. – Guybrush Apr 10 '18 at 11:19
  • yes, that worked for me. I _am_ @Anupam :) – Anupam Apr 10 '18 at 11:30
  • Lol :) Sorry for the confusion, I didn't see you answered your own question ;-) – Guybrush Apr 10 '18 at 11:36
  • 7
    What about Windows? – ianbroad Jan 21 '19 at 19:18
  • @Guybrush , do you have any guidance for Windows users? – mike_butak May 08 '20 at 14:27
  • @mike_butak I guess that installing a newer version of python should do the job. – Guybrush May 10 '20 at 07:43
  • @Guybrush it turned out to be simply my vpn. I had to turn it off. – mike_butak May 11 '20 at 15:30
  • @ianbroad Windows using git bash, the above curl command works for me. Then $python -m pipenv --version (I was having trouble with pipenv.) – Z Kubota Mar 28 '21 at 03:59