Let's say something like this is being returned.
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
I typically see this after installing Python from source using make and then attempting to list packages using pip list or install packages using pip install. I would start by using the absolute path to your Python installation and seeing if the pip list command returns the error.
]# /usr/local/bin/python3.10.2/bin/python3.10 -m pip list
Package Version
---------- -------
pip 21.2.4
setuptools 58.1.0
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
On a Red Hat distribution (CentOS, Fedora, Red Hat), yum list installed or dnf list installed can be used to list the installed OpenSSL packages.
- Python 3.9 can be configured with openssl version 1.0.x
- Python 3.10 and above must be configured with openssl version 1.1.x (e.g. openssl11)
]# yum list installed | grep -i openssl
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
openssl.x86_64 1:1.0.2k-26.el7_9 @rhel-7-server-rpms
openssl-devel.x86_64 1:1.0.2k-26.el7_9 @rhel-7-server-rpms
openssl-libs.x86_64 1:1.0.2k-26.el7_9 @rhel-7-server-rpms
openssl098e.x86_64 0.9.8e-29.el7_2.3 @rhel-7-server-rpms
pyOpenSSL.x86_64 0.13.1-4.el7 @rhel-7-server-rpms
xmlsec1-openssl.x86_64 1.2.20-7.el7_4 @rhel-7-server-rpms
On a Red Hat distribution (CentOS, Fedora, Red Hat), if the openssl-devel package is not installed, use yum install or dnf install to install the openssl-devel package.
dnf install openssl openssl-devel
Likewise, yum install or dnf install can be used to install the openssl version 1.1.x packages if you are installing Python version 3.10 or above.
dnf install openssl11 openssl11-devel
On a Debian distribution (Ubuntu, Mint), ensure the following packages are installed as they are required for Python 3.9 and above.
apt-get install gcc build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdm-dev libbz2-dev libc6-dev libsqlite3-dev tk-dev
Use the openssl version command to confirm that the openssl CLI is working.
]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
Or openssl11.
]# openssl11 version
OpenSSL 1.1.1k FIPS 25 Mar 2021
When installing Python from source, the configure script should contain a few openssl commands.
~]# grep -R Python-3.10.2 -ie 'PKG_CONFIG openssl'
Python-3.10.2/configure: OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
Python-3.10.2/configure: OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
Python-3.10.2/configure: OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
For Python 3.10 and above, you may need to change this to openssl11.
sed -i 's|PKG_CONFIG openssl|PKG_CONFIG openssl11|g' /path/to/configure
Did you find this article helpful?
If so, consider buying me a coffee over at