How To Install Python on Kali Linux

Kali Linux is a secure distribution of Linux which has been derived from Debian and designed especially for system forensics, hacking and advanced penetration testing. It was developed through the rewriting of BackTrack which is now discontinued. It carries different tools that are designed for different information security tasks like testing, penetration, security research, reverse engineering and computer forensics. This article covers all the steps on how to Install Python on Kali Linux.

If you have Python 3.9, 3.8 or 3.7 already installed, we also show you how to upgrade Python on Kali Linux if you want to go to Python 3.10.

Why Install and use Python on Kali Linux

Kali Linux is an operating system specifically developed for ethical hackers. It is used by thousands of hackers and companies worldwide to penetration test and breaks into their networks. It is popular among such audiences due to the various hacking tools it comes packaged with such as Wireshark and Nmap.

This is a bold distribution that has to be disproven. It has more than 580 pre-installed penetration-testing apps to discover. Every program comes with its unique flexibility and use case.

Python uses a lot of scripting and automation and it has various libraries that work with Linux, hence why many security professionals use Python to create scripts used for hacking purposes that they may create based on a vulnerability.

Below are four different categories of the security professionals where Python is used:

  1. Black hat hackers use Python to discover and exploit vulnerabilities, it comes with many network, malware analysis and security libraries that can be utilized by them to compromise an individual or organization. They can also download such applications off the shelf to use to get into a server or device.
  2. Forensic engineers propose a forensic mode through which they can discover and recover data in some instances. Python has a famous imaging library called “PIL” for “Python Imaging Library” used in AI/ML imaging applications.
  3. Security administrators or IT admins are responsible to safeguard both the information and data of their institution so doing this involves running security tests. What they do is use ready-made and custom Python scripts to review the environment and make sure that there are no vulnerabilities that are discovered easily. Many run automated scripts, for example, to check for missing patches, open ports and out-of-date software.
  4. Penetration testers working independently or for bug bounty programs use Kali to perform monitoring and social engineering on businesses. They can check for vulnerabilities, default admin accounts, backups that are not encrypted and passwords, and pages open to the public that shouldn’t be!

ALSO SEE: Download Python for Security and Ethical-Hacking PDF (Free).

Let’s get started…

How to Install or Upgrade Python on Kali Linux (Python 3.9, 3.8, 3.7)

A widely used high-level and object-oriented language has become famous for beginners and experienced programmers for being simple and open-source for a big community. With this, you can build all kinds of apps, from simple scripts to complex machine learning-based issues.

Version 3.7 which is old can be installed using the apt package manager directly. Python 3.9 which is stable has been launched with improvements and security updates. The company has added new modules and extended the existing modules with extra features.

A gentle reminder, Python 3.9 can’t be installed from standard Kali Linux repositories but can be installed from the source once you add it.

Let’s see how to install Python 3.9 on Kali Linux from the terminal. All the commands shall be implemented in the Kali terminal so it is the same for you. So, you need to open the terminal app by clicking Ctrl + Alt + t from the keyboard in Kali.

Step 1: Install necessary packages in Kali core:

You first need to install all the packages and dependencies that are needed to build the source of Python, so, to install the required packages follow the command below:

Python Packages for Kali Linux

Paul@ninja-ide:~#sudo apt update 

Now you need to upgrade Python on Kali Linux:

Upgrade Python on Kali Linux

Paul@ninja-ide:~#sudo apt updgrade

Step 2: Download the latest Python release for Kali Linux:

You need to have the latest Python release from the Python download page, for this, you need to use the “curl” command to download the Python release or alternatively, the way shown in the image:

Download Python 3.9 for Kali Linux

Paul@ninja-ide:~#curl https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz

Step 3: Extract the installer file

Once the download process has been completed, the file shall be saved into the tar extension. Extract the file using the command below with Tar or use alternatives such as p7zip.

Paul@ninja-ide:~#7za l Python-3.9.tgz

It would be best if you navigated to the following directory of Python

Paul@ninja-ide:~#cd /home/paul/Python-3.9.1

By executing this, run the following configuration script in order to prepare your system for Python source code compilation

Paul@ninja-ide:~#./configure –enable-optimizations

If you have issues running it, please run the below command to fix the permissions:

Paul@ninja-ide:~#chmod +x ./configure –enable-optimizations

This shall perform many checks to ensure that all the dependencies are installed on the system. The -enable-optimization is used here to optimize the Python binary by executing many different tests. This sets various variables according to best practices identified by the Python community over the years.

Step 4: Finally, now install Python on Kali Linux

At this point you need to start with the build process by running the command mentioned below:

Paul@ninja-ide:~#make –j4

You shall modify –j in accordance with the cores of the processor. My own laptop has a quad-core so it will be -j4 for me.

Install Python Binaries on Kali Linux

As the build process is completed, you need to run altinstall in order to Install python binaries on Kali Linux:

Paul@ninja-ide:~#make altinstall

Keep in mind to never use “make install” to install binaries as it will automatically overwrite the binary files.

Finished! Python has now been installed on Kali Linux. You can now check the version by running the command below if you want to verify it:

Paul@ninja-ide:~#python –-version

Similar Python installation articles:

Conclusion

This article covered extensively all the major instructions required to Install Python on Kali Linux. Python is without a doubt a very powerful scripting language but it still isn’t available or installed by default with operating systems, hence you have to manually install it.

Do let me know in the comments area below how easy you find the above and why you choose Python over any other language.

Previous articleDownload PyCharm IDE Free for Windows 11 2024 (Latest Release)
Next articleThe Best Collection of Free Code Editors and IDEs for Linux
Paul Carruthers
Paul is an avid programmer who specializes in Python and Java with over 16 years of experience in the field. He loves automating complex tasks and creating useful scripts to streamline work and make life easier. He is also a massive fan of Linux and currently uses it as his main desktop OS. When he is not staring at code, he loves hiking and swimming in different parts of the world.

LEAVE A REPLY

Please enter your comment!
Please enter your name here