How to Install Python 2.7 in Kali Linux 2021
Python 2.7 – Installation Guide for Kali Linux
In this post, am going to show you how to install Python 2.7 in Kali Linux without any errors (Import error, bash: pip: command not found).
Python 2.7.2 was released on June 11th, 2011.
The Python 2.7 series is scheduled to be the last major version in the 2.x series before 2.x moves into an extended maintenance period. The 2.7 series contains many of the features that were first released in Python 3.1.
End of Python 2.7 :
Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Python 2.7 causes lot of bugs due to end of life.
Install Python2 :
- Prerequisites for Python
- Download Python 2
- Compile python source code.
- Check python version.
Step 1 : Prerequisites for Python 2
You must want to install the following prerequisites on your system. Open a terminal and execute the following commands on your system for installing all the required dependencies.
mk007@linuxlia:~$ sudo apt-get update mk007@linuxlia:~$ sudo apt-get install build-essential checkinstall mk007@linuxlia:~$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev li
Step 2 : Download Python 2.7
Open a terminal and switch the directory to /usr/bin.
mk007@linuxlia:~$ cd /usr/src
Here run the following command for downloading python2 tgz packages.
mk007@linuxlia:~$ wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
Now extract the tgz packages by running the below command.
mk007@linuxlia:~$ sudo tar xzf Python-2.7.18.tgz
Step 3 : Compile Python Source
Use the following commands to compile Python source code on your system using altinstall.
mk007@linuxlia:~@ cd Python-2.7.18 mk007@linuxlia:~@ sudo ./configure --enable-optimizations mk007@linuxlia:~@ sudo make altinstall
make altinstall command is used to prevent replacing the default python binary file /usr/bin/python.
Step 4 : Check Python Version
Check the version of python using the following command.
mk007@linuxlia:~@ python2.7 -V Python 2.7.18
How to remove Python 2 Packages?
Open a terminal and run the following command for removing outdated python2 packages.
mk007@linuxlia:`$ sudo apt-get autoremove python-pip
If you have any doubts about this post please leave a comment otherwise ping me in Instagram. Am ready to solve your doubts.