13

I am not able to install any Python libraries. I am using pip 9.0.1 and python 2.7. I am getting the following error:

EN-NishantS:~ 8417$ pip install presto-python-client
Collecting presto-python-client
  Could not find a version that satisfies the requirement presto-python-client (from versions: )
No matching distribution found for presto-python-client

On running with pip install -vvv I am getting the following:

Collecting presto-python-client
  1 location(s) to search for versions of presto-python-client:
  * https://pypi.python.org/simple/presto-python-client/
  Getting page https://pypi.python.org/simple/presto-python-client/
  Looking up "https://pypi.python.org/simple/presto-python-client/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
  "GET /simple/presto-python-client/ HTTP/1.1" 403 170
  Status code 403 not in [200, 203, 300, 301]
  Could not fetch URL https://pypi.python.org/simple/presto-python-client/: 403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/simple/presto-python-client/ - skipping
  Could not find a version that satisfies the requirement presto-python-client (from versions: )
Cleaning up...
No matching distribution found for presto-python-client
Exception information:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 514, in find_requirement
    'No matching distribution found for %s' % req
DistributionNotFound: No matching distribution found for presto-python-client
Looking up "https://pypi.python.org/pypi/pip/json" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
"GET /pypi/pip/json HTTP/1.1" 403 170
Status code 403 not in [200, 203, 300, 301]
There was an error checking the latest version of pip
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/outdated.py", line 128, in pip_version_check
    resp.raise_for_status()
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/models.py", line 862, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/pypi/pip/json
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
nish
  • 6,230
  • 17
  • 60
  • 113
  • This is probably the root cause: `TLSv1.2+ is required for url: https://pypi.python.org/`. (TLS is the **s** in http**s**). How old is your system? – VPfB Apr 09 '18 at 13:55
  • 1
    @VPfB: I am using MacOS Sierra – nish Apr 09 '18 at 14:08
  • @nish sorry saw the message too late. Did you install pip via brew? You might want to update it via brew or try "sudo easy_install -U pip" instead? – Dominique Barton Apr 09 '18 at 14:11
  • @DominiqueBarton Don't remember how I installed it. When upgrading via easy_install I get `pip 9.0.1 is already the active version in easy-install.pth` – nish Apr 09 '18 at 14:17
  • 1
    @nish Sierra is not old, there should be no problems with TLS v1.2 support unless something is installed or configured incorrectly. – VPfB Apr 09 '18 at 14:46
  • 1
    I faced the same error recently. Got resolved by installing pip as follows: `curl https://bootstrap.pypa.io/get-pip.py | python`. See [this](https://stackoverflow.com/a/49748494/1526703) – Anupam Apr 10 '18 at 08:27
  • If you're experienced it only "sometimes", then it's probably because of the TLSv1.0/TLSv1.1 rolling brownouts https://status.python.org/incidents/hdx7w97m5hr8 – Dominique Barton Apr 10 '18 at 10:59

7 Answers7

9

On Mac you can do sudo curl https://bootstrap.pypa.io/get-pip.py | python

Esir Kings
  • 1,630
  • 14
  • 27
  • doesnot work for me. I have mac 10.10.5. I am getting permission error [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-7.1.2.dist-info/DESCRIPTION.rst' – Anuj Gupta May 13 '18 at 14:27
6

I was having the same issue today trying to install Django.

I just re-installed pip. Get get-pip.py from https://pip.pypa.io/en/stable/installing/ and just run python get-pip.py in your virtualenv. That should overwrite the existing installation and update the SSL certificate.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
bizyb
  • 61
  • 1
  • 2
6

It seems this issue is generating quite a few questions on Stack Overflow about various packages not getting installed using pip install package-name. So I thought I'll copy over my answer from here for more clarity on the issue:

The solution is to upgrade pip to the latest version.

However, upgrading pip via pip install --upgrade pip may not upgrade it correctly (it will show it's up-to-date even when it's not).

So (for Mac users, for example), we need to upgrade pip as follows:

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

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.

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
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Anupam
  • 12,420
  • 12
  • 51
  • 82
5

A coworker also on macOS v10.12 (Sierra) just solved this by running brew install python@2 and then overwriting the previous version. It seems like the the version off the Python website is not bundling the correct OpenSSL version.

I think someone has also filed a bug for this to Python directly: OS X system OpenSSL deprecated - installer should build local libssl

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
4

Your HTTP request to PyPI fails with an HTTP 403 (Forbidden) error:

HTTPError: 403 Client Error: TLSv1.2+ is required for url:

https://pypi.python.org/pypi/pip/json

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
3

I successfully upgraded Python 3 on macOS v10.13 (High Sierra) using sudo pip3 install --upgrade pip.

To upgrade the High Sierra version 2.7 I had to use sudo pip2 install --upgrade pip.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Milliways
  • 1,215
  • 1
  • 11
  • 23
1

I had a similar problem.

The problem was in an old version of OpenSSL linked to the system Python installation.

So I've uninstalled all Python distributions from the system and installed the last Python implementation with brew install python@2.

You can check the OpenSSL version linked to Python like this:

Python 2.7.14 (default, Mar 22 2018, 15:04:47)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2o  27 Mar 2018'
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Dmitriy Demidov
  • 433
  • 2
  • 5
  • 15