In Linux, there are two versions of python available Python2 and Python3, which provide the facility as the alternative of the bash utility for scripting. The SSL is a module of Python that gives access to the transport layer (Socket Layer) for security peer authentication and encryption for network sockets. The pip utility does the installation of the Python module. During the installation of any module using the pip command, users can face the error “ssl module in Python is not available”.
This post will demonstrate the reason and the solution for the error “ssl module in Python is not available”. The content for the post is:
Reason: Missing Packages For SSL
The reason for the error “ssl module in Python is not available” is the missing libraries that are needed for installing any package using the pip utility. By installing the necessary packages for the SSL module, the error can be resolved.
Let’s move toward the solution.
Solution: Installing Necessary Packages For SSL and Python
If you are facing the error for installing any packages using the pip command, first try to upgrade the pip3 to the latest version. To do this, run the below command in the terminal:
$ pip3 install --upgrade pip
The pip3 will be upgraded to the latest version.
Now, install the necessary libraries such as “libbz2dev”, “libffi-dev” and “libssl-dev” in the Linux operating system:
$ sudo apt install libbz2-dev libffi-dev libssl-dev
$ sudo yum -y install bzip2-devel libffi-devel openssl-devel
After that, download the zip file of the Python file according to the version of the Python. As in our case, we are downloading Python 3.10.1 using the wget command:
$ wget https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz
Once the file is downloaded, extract the file by right-clicking:
Once extracted, jump into the folder through the terminal using the “cd” command:
$ cd Python-3.10.1
After going into the extracted directory, check all the files dependencies for the Python:
Now, compile the files of the extracted Python directory using the following command:
$ make && sudo make install
Once the compiling process is completed, try to install any package using the pip3.
$ pip3 install [package_name]
After performing the above operations, the error will be resolved.
The reason for the error “ssl module in Python is not available” is the missing libraries for the SSL module. To fix this error, upgrade the pip to the latest version and install the missing libraries, download the file of the Python version, extract it, and compile the extracted directory. This write-up has illustrated the reason and the solution for the error “ssl module in Python is not available”.