Debian

How to Install Python on Debian 10


Python programming language is one of the most widely used high level and object-oriented languages. Python is becoming famous for beginners and experienced programmers due to its simplicity and easy to learn syntax. Python is a versatile and open-source programming language for a large community. You can use this language to build almost all kinds of applications, from a small, simple script to complex machine learning-based problems. The old version of python 3.7, you can install directly by using the apt package manager. Python 3.9, a stable version, has been launched with many other improvements and security updates. The company added multiple new modules and extended the existing modules with some extra features in this version.

You can’t install Python 3.9 from the standard Debian 10 repositories. However, you can install it from the python source.

This tutorial will cover the installation procedure Python 3.9 on the Linux system Debian 10 through the command line. All commands we will implement in the Debian 10 Terminal application. Therefore. Open the terminal application by pressing ‘Ctrl+Alt+t’ or open it directly from the Debian 10 installed applications and start the installation!

Note: All steps we will run under the Sudo privileges.

Installation of python on Debian 10

Python installation is a very straightforward and relatively simple process that you can complete in a few minutes by following the below-mentioned steps:

Step 1: Installing necessary packages or dependencies

First, you need to install all packages and dependencies required to build the python source. Therefore, to install all the required packages, type the below-mentioned command:

$ Sudo apt update & sudo apt upgrade

$ sudo apt install wget build-essential libreadline-gplv2-dev libncursesw5-dev \

libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Step 2: Download Python Release

In this step, you will download the latest python release from the python download page. To do this, use the ‘curl’ or ‘wget’ command to download the python release. To our best knowledge, the latest release of python at the time of article writing is 3.9. So, grab this release by executing the following command:

$ wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz

Step 3: Extract the tar file

Once the download process is completed. The downloaded file will save into the .tar extension. So, you need to extract this file by using the following command:

$ tar xzf Python-3.9.1.tgz

Step 4: Navigate and execute the configuration script

Navigate into the following python directory:

$ cd Python-3.9.1

Now, by executing the following command, run the below-mentioned configuration script to prepare your system for python source code compilation:

$. /configure --enable-optimizations

The above script will perform several checks to ensure that all of the dependencies are installed on your system. The ‘–enable-optimizations’ is used here to optimize the Python binary by executing many tests.

Step 5: Install python

Now, start the build process by running the below-mentioned command:

$ make -j 2

You will modify -j according to your processor’s cores. To find the number by typing the ‘nproc’ command.

Once the above build process is completed, run the following command to install python binaries on your system:

$ sudo make alt install

Never use ‘make install’ to install the binaries because it will overwrite the binary of python 3.

Python is installed on your system, Debian 10. You can check the installation of python 3.9 by running the following command:

$ python3.9 --version

Or

$ python3.9 -V

Conclusion

We have shown in this article how you can install Python 3.9 on Debian 10 Linux system. We have explained each step-in detail. By executing the steps mentioned earlier, you can easily install the latest Python release on your system. You can get more information about the python language from various internet resources. Thanks for reading this tutorial.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.