[Fixed] SSL module in Python is Not Available

If you are using the pip command to install the SSL module and get an error, don’t worry; we’ve got you covered. This blog will provide everything you will require to fix this error. We will discuss the SSL module in PPython, so let’s get started.

SSL module in Python

This module is used to create secure sockets layer (SSL) connections. It allows you to handle SSL certificate verification and self-signed certificates. SSL module in Python is a library that helps you create your own SSL server and client using Python. It allows you to easily create your own HTTPS server with the help of Python. One can encrypt data before its transmission over a network (e.g., HTTP) or by storing it in a database (e.g., SQLite). It supports critical exchange algorithms such as Diffie-Hellman and ECDHE.

The Python SSL library makes creating a secure connection between two applications accessible by providing an easy-to-use API that supports multiple encryption algorithms and provides access to various types of certificates (X509v3, PKIX, and OpenPGP).

The SSL module in Python is not available by default. It can be installed using pip or easy_install.

Why is the SSL module not available in Python?

This happens when some libraries are missed out during installation. To solve this, you can re-install all libraries.

Resolution of Error

Update pip. Make sure you have the current upgraded version of this command.

pip3 install --upgrade pip

Some necessary libraries include:

  •  libffi-dev
  • libssl-dev
  • libbz2dev

All these need to be downloaded on your system.

SSL module for ubuntu

Install the necessary libraries on ubuntu too.

sudo apt install libbz2-dev libffi-dev libssl-dev

Later, install the latest version of Python and extract the python file. Next, open the terminal and cd into the Python directory. Now, configure all files using $ ./configure command in terminal. You need to put together all files using

$ make && sudo make install

Lastly, you have to install the required packages with this command:

$ pip3 install [pname]
#here, pname refers to package name

How to fix this issue on Windows

Go to https://pypi.python.org/simple/requests and install the recent version. Unzip it and then install it in another folder. Next, just run the given command and you’re good to go.

pip install c:\temp\requests-2.21.0

How to fix this issue on Red Hat/CentOS

In case you are using CentOS, first you have to enter the first command on the terminal. This will ensure download of ssl module. Next, you need to work on recently installed zip version of Python. Just configure and rest of the steps are same.

sudo yum -y install bzip2-devel libffi-devel openssl-devel
wget https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz

How to fix this issue on Mac

There’s an easy way out for Mac users. In case you have encountered an error related to the unavailability of the ssl module, it might be because the operating systen on Mac has changed the setup to LibreSSL. Therefore, downloading a zip file from https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip will help the user in fixing the ‘SSL module in python is not available’ error.

How to fix this issue on Termux

In case you obtain the error while working on Termux, you should know that just updating the packages will also help. Upgrade them to the most recent versions and then you won’t get the error anymore for absence of ssl module.

apt update && apt full-upgrade

How to fix this issue on Raspberry Pi

Make sure that all necessary packages ars installed. Use the given statements to do the same. Install and re-install Python with the latest version also.

sudo apt-get install build-essential checkinstall 
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

How to fix this issue on Pycharm

In place of creating a virtual environment, try working with conda or a new interpreter. Also, install the latest version of ssl on your system. When the upgraded version isn’t installed, it gives an error.

Resolving the error on Anaconda

You may get this error on Anaconda when the module is installed in another folder. Say, it might be in the bin folder. So, you need to copy the given files in D:\Anaconda3\DLLs folder. Then only you can fix the given error.

libcrypto-1_1-x64.*
libssl-1_1-x64.*

Alternative to SSL module

If SSL module in Python is not available and you can use the HTTP module instead. The HTTP module provides the same functions as the SSL module but without the SSL encryption.

The http.server() function initiates a HTTP server and returns a generator object that yields new requests as they come in. The http.request() function also initiates a HTTP request, which returns an HttpResponse object containing the server’s response to that request.

FAQs

Can I disable SSL after installation?

Yes, this can be done through Internet Options settings. Go to advanced then security and double click on the SSL version installed. This will disable it.

Is SSL included in Python?

Use the pip command to install ssl on your server.

What is the use of SSL module in Python?

The SSL module enables us to use SSL certificate and TLS security for better and safer delivery of data packets across the network.

Conclusion

This article explained how to resolve the ‘SSL module in Python is not available’ error. It requires upgrading the pip command, installing the latest Python version, and the necessary SSL libraries.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments