Lele Canfora
Lele Canfora

Reputation: 77

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

I recently upgraded to Ubuntu 21.04 that comes with Python 3.9.4 but I needed to create a virtual environment with 3.8.

I manually installed 3.8.10 with this guide: https://hackersandslackers.com/multiple-versions-python-ubuntu/ and created a venv with python3.8 -m venv NAME. I activate it, the Python and Pip version are correct.

Problem is when I go and try installing wheel I get this error: WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

I don't get the same error if I use the system python version to create a venv.

I checked the (many) other questions related to this but most of them are for windows or mac or a remote installation, I'm on a local machine.

Upvotes: 3

Views: 29981

Answers (2)

Gabriel Furstenheim
Gabriel Furstenheim

Reputation: 3628

Reinstalling python fixed it for me.

pyenv install v3.8

>
pyenv: /home/gabi/.pyenv/versions/3.x.x already exists
continue with installation? (y/N) y
...

Upvotes: 3

L.Grozinger
L.Grozinger

Reputation: 2398

libssl-dev is required to build the ssl module from source.

If you install Python from the package repositories, you will be installing a pre-built binary, so you won't need the openssl development files on your own machine, because these files are sort of 'baked-in' to the release.

But if you build Python from source yourself, you will need to install the libssl-dev (openssl development files) package in order to build Python with the ssl module.

You can check whether you have libssl-dev installed by looking at the output of:

dpkg -s libssl-dev

If it is not installed, you can install it with (may require privileges e.g. sudo):

apt-get install libssl-dev

If you then rebuild Python from source the ssl module should be available.

NOTE: There are other dependencies too which might be missing and result in a less than fully-functional Python installation. Pay attention to the output you get when building. A (maybe incomplete) list of these dependencies' names in the Ubuntu repositories is: libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Upvotes: 3

Related Questions