Explain Codes LogoExplain Codes Logo

"ssl module in Python is not available" when installing package with pip3

python
pip-installation
ssl-module
python-ssl
Alex KataevbyAlex Kataev·Mar 7, 2025
TLDR

Swiftly fix the "ssl module in Python is not available" by reinstalling Python with SSL support. Execute these commands:

Ubuntu/Debian:

# Who doesn't love a fresh reinstallation? sudo apt-get install --reinstall python3-openssl

macOS:

# Like giving Python a refreshing brew! brew reinstall python

For Windows, download the Python installer with SSL from python.org and make sure to select "Add Python to PATH".

First aid: Reinstall

Specific SSL dependencies

Ensure the right versions of libcrypto and libssl DLLs, especially for Windows:

pip3 install --upgrade libssl

System specialties

On macOS, switch OpenSSL version using brew switch openssl in case of issues. For Ubuntu:

sudo apt-get install libssl-dev libffi-dev

Conflict cleansing

Check for and rename any conflicting DLL versions in Windows\System32 to give way to SSL.

Advancing: Build Python with SSL

Building Python

Download the Python source code and configure the build process to include SSL:

./configure --with-ensurepip=install --with-ssl make make test sudo make install

Installation location

Install Python in /usr/local/bin on Unix systems to avoid conflicts.

Post-install validation

Test the pip3 and ssl module with import ssl in Python to verify functionality.

Deep-Dive: Advanced SSL handling

Custom Python-SSL builds

Advanced SSL in Python requires the SSL libraries to be linked to Python:

LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" ./configure --with-openssl=/usr/local/opt/openssl
# Proper SSL module is like choosing the right wand in Harry Potter

SSL "module not found"

Post-update SSL errors can be solved by a pip3 and Python quick-fix:

python3 -m ensurepip --upgrade python3 -m pip install --upgrade pip

Version Matchmaking

Make sure to match the OpenSSL version with your Python installation to avoid a sour date.