pip: Cannot install pip for python3.7 on Ubuntu 16.04 32bits :

Environment

  • pip version: Not installed yet for python3.7
  • Python version: Python 3.7.0
  • OS: Ubuntu 16.04 32bits

Description

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Expected behavior

The installation should be working How to Reproduce

  1. Run curl -qs https://bootstrap.pypa.io/get-pip.py | sudo -H /usr/bin/python3.7 -

Output

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
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("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@deveshks Pb. solved. After upgrading from Ubuntu 14.04 32b, the deadsnakes repo was disabled and the python3.7 package was NOT upgraded :

$ apt-cache policy python3.7
python3.7:
  Installed: 3.7.0-1+trusty1
  Candidate: 3.7.7-1+xenial1
  Version table:
     3.7.7-1+xenial1 500
        500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main i386 Packages
 *** 3.7.0-1+trusty1 100
        100 /var/lib/dpkg/status

Now, it is solved :

$ apt-cache policy python3.7
python3.7:
  Installed: 3.7.7-1+xenial1
  Candidate: 3.7.7-1+xenial1
  Version table:
 *** 3.7.7-1+xenial1 500
        500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main i386 Packages
        100 /var/lib/dpkg/status
$ python3.7 -c "import ssl"
$ curl -qs https://bootstrap.pypa.io/get-pip.py | sudo -H /usr/bin/python3.7 -
Collecting pip
  Using cached pip-20.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.1
$ pip3.7 -V
pip 20.1 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

What is then the proper way to install pip when a recent version of python was installed from a package manager apt repository ?

To be honest, the answer is to request that the maintainers of that repository package the latest version of pip.

Or you can do a --user install of pip, but you’ll need to make sure your PATH is set correctly, so that your user install gets used in preference to the system install. (And I have a nasty feeling that Ubuntu patches pip in a way that makes user installs slightly non-standard, so you’ll need to be prepared for that.

Unfortunately it is all very system-dependent, and not somethingthe pip maintainers can necessarily help with (the wrapper in /usr/bin/pip3 isn’t installed or owned by pip, so we have no real control over what it does. The issue #5599 linked in the message you get is the best resource we have for people hitting issues in this area - it’s intended for users to share their experiences and help each other out.

IIUC, that command might be upgrading the pip which is packaged with the python installation you used. Perhaps you can see which pip and pip --version to be sure.

I’ve seen this exact problem popped up occassionally for a while now, which makes me wonder whether pip should fail more gracefully if SSL is unavailable but required (add a link pointing to a post in the error message explaining what’s going on, for example.)

@uranusjr If it’s not possible to use http only locations, then replace this warning by an error : ERROR: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. instead of : WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

The relevant code which raises the warning is

https://github.com/pypa/pip/blob/43426eea344c626153efa46f3a9bc6b62d7e8a69/src/pip/_internal/models/search_scope.py#L52-L61

where the has_tls() method checks where _ssl module is available in Python or not.

https://github.com/pypa/pip/blob/43426eea344c626153efa46f3a9bc6b62d7e8a69/src/pip/_internal/utils/compat.py#L77-L86

Can you try import _ssl to verify if the ssl module is present in your python installation? I think that this error might not have to do with pip, but with the underlying python.

There is also IS_PYOPENSSL which tries to see if pyopenssl is available or not, but I couldn’t make much sense of how that is used.