41

I downloaded the Python 3.5 source code and ran the following:

$ tar -xf Python-3.5.2.tar.xz
$ ./configure --with-ensurepip=upgrade
$ make
$ sudo make altinstall

It proceeded well until make. When sudo make altinstall ran, it printed:

Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS

What went wrong?

Asclepius
  • 57,944
  • 17
  • 167
  • 143
gil Got
  • 421
  • 1
  • 5
  • 7

8 Answers8

71

You are most likely not compiling Python with SSL/TLS support - this is likely because you don't have the SSL development dependencies installed on your system.

Install the following dependency, and then re-configure and re-compile Python 3.5.

Ubuntu

apt-get install libssl-dev

In addition it is recommended to install the following.

apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev

CentOS

yum install openssl-devel

In addition it is recommended to install the following.

yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
xiº
  • 4,605
  • 3
  • 28
  • 39
eandersson
  • 25,781
  • 8
  • 89
  • 110
  • 1
    I found the solution, and the solution was to type "python3" on the terminal. – gil Got Jun 09 '16 at 14:14
  • 1
    @eandersson For CentOS, it's just `openssl-devel` that is missing in the context of the error in question; the other packages are inconsequential, although I acknowledge that some or all of the others may be required for the build. – Asclepius Oct 01 '16 at 03:16
  • 3
    Yep, but the others are recommended as part of the build process. Not strictly necessary, but also not harmful. – eandersson Oct 01 '16 at 03:17
  • 1
    After searching for 8 hours and trying out a dozen different fixes, this libssl-dev fix finally worked. Please upvote this as much as possible. Thank you very much eandersson. Verified on - Ubuntu x64 16.04.1 LTS, Intel x64 chipset, Python 3.6.0 compiled from source. – Quest Monger Jan 22 '17 at 13:04
  • In my case, I had to reboot my centos-6.5, after installation of above packages. not sure, why. may sound silly. – Rohit Verma Apr 23 '17 at 03:51
  • As-with more-current SSL, this is a misleading answer. Put simply, the SSL requirement for Python changed between 3.4.x and 3.7.x -- trying to compile the older Pythons with newer SSL breaks in this fashion, and you'll see a similarly obtuse error when trying to compile newer Python on older systems (eg, Debian < 9). (Eg. ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?) – RVT May 19 '20 at 02:18
11

Please note that besides that as of version OpenSSL 1.1.0 (included from Ubuntu 18.04 repositories, I am not sure for other Linux distributions) there are python vesions that may have compilation issues (see this question and my answer), in short:

Python <3.4.5 and Python <3.5.3 have not implemented this newest version of OpenSSL, most likely other major Python versions suffer the same issue. The fix is to download the minor version that implements the fix (or newer). Check the full changelogs to check which minor version that is (changelog for 3.4 and 3.5)

Laurens
  • 331
  • 2
  • 8
  • 1
    there is no 3.4 version, not even the latest 3.4.9 that will install with openssl 1.1.0. will produce the exact same error as for the OP. When you have legacy systems running Django 1.7.8, (or whatever, which depend on old python modules) you are simply out of luck. – semiomant Oct 18 '18 at 08:42
  • OP did not ask about legacy systems and/or configurations. Therefore I did not include this in my answer. – Laurens Oct 24 '18 at 12:09
  • it was not meant as criticism, bur as an additional hint to anyone stumbling on this while encountering the error. I simply found this question (and your awnser) the most useful place on my search and wanted to add a sidenote by comment. Sorry i wasn't clear enough. – semiomant Nov 16 '18 at 13:34
  • I can't install Python 3.4.10 from pyenv or asdf with the same error as OP gets :( It seems that we will never be able to install these EOL versions again. – Andrey Semakin Nov 21 '19 at 06:05
  • 1
    Useful link for a workaround: https://github.com/pyenv/pyenv/issues/945#issuecomment-409627448 – Andrey Semakin Nov 21 '19 at 06:22
  • Probably the only relevant answer for the problem – dawid Sep 14 '21 at 03:44
11

On Ubuntu 18.04 only this worked for me

sudo apt-get install libssl1.0
y0j0
  • 3,369
  • 5
  • 31
  • 52
4

CentOS:

If you didn't have openssl-devel at the time of installing python, pip 8.1.1 won't install. After installing openssl-devel, reinstall python. This time it should install pip just file.

user4212639
  • 489
  • 6
  • 6
2

I tried to install Python 3.4.10 using asdf but got following error:

$ asdf install python 3.4.10
python-build 3.4.10 /home/br0ke/.asdf/installs/python/3.4.10
Downloading Python-3.4.10.tar.xz...
-> https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tar.xz
Installing Python-3.4.10...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Fedora 30 using python-build 1.2.15-2-g22c02022)

Inspect or clean up the working tree at /tmp/python-build.20191121110112.9959
Results logged to /tmp/python-build.20191121110112.9959.log

Last 10 log lines:
(cd /home/br0ke/.asdf/installs/python/3.4.10/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
    case upgrade in \
        upgrade) ensurepip="--upgrade" ;; \
        install|*) ensurepip="" ;; \
    esac; \
     ./python -E -m ensurepip \
        $ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

It may mean that I have too fresh OpenSSL version installed in my system and this version is not supported by Python I'm trying to build. I managed to install Python 3.4.10 on my Fedora 30 machine (has OpenSSL 1.1+ by default) using the following steps:

  1. Temporary remove openssl-devel if it is installed as it will conflict with older version:
$ sudo dnf remove openssl-devel
  1. Install compat OpenSSL 1.0 packages:
$ sudo dnf install compat-openssl10 compat-openssl10-devel
  1. Build Python 3.4.10 (I use asdf but it should work with pyenv as well):
$ asdf install python 3.4.10
  1. Remove compat library and install modern instead to be able to build something more fresh next time:
$ sudo dnf remove compat-openssl10-devel
$ sudo dnf install openssl-devel

Inspired by this workaround with help from Fedora community people.

Andrey Semakin
  • 2,032
  • 1
  • 23
  • 50
  • I have problems installing `compat-openssl10` and `compat-openssl10-devel` in fedora 35. Any advice ? – rvcristiand Nov 26 '22 at 16:54
  • @rvcristiand, seems like Fedora 35 has dropped the compat package from their repos. To get it working, you'll need to download .rpm package and install it manually. I found a link here but haven't tried it myself: https://www.reddit.com/r/zerotier/comments/t9u7n6/missing_openssl_library_in_fedora_3435_solution/ – Andrey Semakin Nov 28 '22 at 07:30
1

If you use Manjaro Linux, you can use this:

sudo pacman -S openssl , check

Denis L
  • 237
  • 2
  • 13
0

If you are using RedHat Enterprise Linux, you can use this:

yum install openssl-devel -y
0

CentOS or RHEL machine Python3(3.7.0) ssl not supported as of now.

pip installation supported with Python <=3.6

Sadashiv
  • 53
  • 5