3

The following command

==> pip install django -vvv

results in the following error :

==> pip install django -vvv
Collecting django
  1 location(s) to search for versions of django:
  * https://pypi.python.org/simple/django/
  Getting page https://pypi.python.org/simple/django/
  Looking up "https://pypi.python.org/simple/django/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
  "GET /simple/django/ HTTP/1.1" 403 170
  Status code 403 not in [200, 203, 300, 301]
  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: )
Cleaning up...
No matching distribution found for django
Exception information:
Traceback (most recent call last):
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/commands/install.py", line 299, in run
    requirement_set.prepare_files(finder)
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 512, in _prepare_file
    finder, self.upgrade, require_hashes)
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/req/req_install.py", line 273, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/index.py", line 489, in find_requirement
    'No matching distribution found for %s' % req
pip.exceptions.DistributionNotFound: No matching distribution found for django
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 "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/utils/outdated.py", line 128, in pip_version_check
    resp.raise_for_status()
  File "/Users/coder/repos/appliaison/bitbucketrepos/rndflo-portal/venv/lib/python3.5/site-packages/pip/_vendor/requests/models.py", line 840, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/pypi/pip/json
Arunabh Das
  • 13,212
  • 21
  • 86
  • 109

1 Answers1

4

As shown in the error log, this is the cause:

403 Client Error: TLSv1.2+ is required for url: https://pypi.python.org/simple/django/

As mentioned in this answer, you 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 OSX version 10.12 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)

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/

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

pip install --upgrade setuptools
Anupam
  • 14,950
  • 19
  • 67
  • 94