hafiz031
hafiz031

Reputation: 2670

SSLError("Can't connect to HTTPS URL because the SSL module is not available.") in pip command

In my Ubuntu 20.04. I am using two python versions. One of them is Python3.8.2 which came with my Ubuntu installation and another one is Python3.7.5. I installed Python3.7.5 using update-alternatives alongside the system default version. But now the problem is no pip command is working on Python3.7.5. Although pip is available in this (Python3.7.5) installation and while printing the version it shows the following (using command pip3.7 -V):

pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

But whenever I try to install a package using it always shows the error mentioned in the title. For example while installing the following package:

sudo pip3.7 install intel-tensorflow==1.15.2

The following error is thrown:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting intel-tensorflow==1.15.2
  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/intel-tensorflow/
  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/intel-tensorflow/
  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/intel-tensorflow/
  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/intel-tensorflow/
  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/intel-tensorflow/
  Could not fetch URL https://pypi.org/simple/intel-tensorflow/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/intel-tensorflow/ (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 intel-tensorflow==1.15.2 (from versions: none)
ERROR: No matching distribution found for intel-tensorflow==1.15.2
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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

Why this is actually happening? Again it shows the same error for all pip3.7 installations no matter which module I am going to install. Also there is no such problems like that whenever I am using the system default python version (Python3.8.2).

Upvotes: 15

Views: 104414

Answers (7)

Andrea Bisello
Andrea Bisello

Reputation: 1215

for windows,

delete the venv folder and recreate again.

Upvotes: -1

Khalil Meg
Khalil Meg

Reputation: 781

openssl is no more supported in centos7, To fix this issue, you must build python using openssl11 package instead of openssl, to do so:

  • first install openssl11

    sudo yum install -y epel

    sudo yum install -y openssl11-devel

  • build python:

    cd Python-3.1X.X

    sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure

    ./configure --enable-optimizations

    make altinstall

Upvotes: 3

Dhruv
Dhruv

Reputation: 1

If you've installed pyenv, uninstall it.

rm -rf $(pyenv root)

Upvotes: -1

Mykola Tetiuk
Mykola Tetiuk

Reputation: 362

Ubuntu 22.04

python -m pip install virtualenv

That has revealed that I needed to add ~/.local/bin to $PATH

export PATH=~/.local/bin:$PATH

After that pip install --user conan or pip install conan should be successful.

Upvotes: 0

Ncrefe
Ncrefe

Reputation: 41

For windows run following command before you run your actual command:

choco install wget openssl

Upvotes: 4

altschuler
altschuler

Reputation: 3922

On Manjaro/Arch Linux I had to install openssl-1.1.

Running import ssl in a python repl revealed that libssl.so.1.1 was being read but not found.

Upvotes: 6

Kirk
Kirk

Reputation: 1845

TL;DR you're probably missing some system dependencies. sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

Read below for the full details on how we got there.

The error states that the SSL python module is not available; meaning you either don't have an appropriate ssl lib installed (probably not since you state the system python can pip install fine), or the python you built from source or otherwise installed doesn't include the ssl module.

If you built it from source, you need to be sure to set the configuration option --with-openssl.

Also, I'd really caution against sudo pip installing anything. Use something like virtualenv to have separate python environments from the system python or other python versions you install.

EDIT:

Upon closer examination, the python configure script appears to enable ssl support by default, assuming the dev headers are present. Make sure all the dev headers are present with sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget, then retry configuring and building python.

Upvotes: 22

Related Questions