Python is a widely used high-level programming language. Its advantages such as ease of learning and strong scalability make it the language of choice for many developers. Debian is a popular Linux operating system that supports Python 3.9 and can easily install Python 3.9 with a few simple steps. In this article, we will describe how to install Python 3.9 on Debian.
Step 1: Update the package list Before installing Python 3.9, make sure you update the APT package list to get the latest package information. Enter the following command in the terminal:
``` sudo apt update ```
This will update your package list and prepare all updates.
Step 2: Install Dependencies Before installing Python 3.9, you need to install some necessary dependencies. Enter the following command in the terminal:
``` sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget ```
This will install the necessary dependencies to support compilation and installation of Python 3.9.
Step 3: Download the source code of Python 3.9 Download the source code file of Python 3.9 and save it to the current directory. Enter the following command in the terminal:
``` wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz ```
This will download the source code files for Python 3.9 and save them to the current directory.
Step 4: Extract the source code Enter the following command in the terminal to extract the source code for Python 3.9:
``` tar -xf Python-3.9.0.tgz ```
This will unzip and save the source code files for Python 3.9 to the current directory.
Step 5: Enter the source code directory Enter the following command in the terminal to enter the source code directory of Python 3.9:
``` cd Python-3.9.0 ```
This will go into the Python 3.9 source code directory.
Step 6: Configure and compile the source code Enter the following commands in the terminal to configure and compile the source code for Python 3.9:
``` ./configure --enable-optimizations make -j 4 ```
This will compile the source code for Python 3.9 using configure options and compile options. Note that the `-j` option specifies the number of threads for parallel compilation, which can be adjusted according to your CPU core count.
Step 7: Install Python 3.9 Enter the following command in the terminal to install Python 3.9:
``` sudo make altinstall ```
This will install Python 3.9 with the `altinstall` option to prevent overriding the default Python version.
Step 8: Verify that Python 3.9 is successfully installed Enter the following command in the terminal to verify that Python 3.9 is successfully installed:
``` python3.9 --version ```
If the output is similar to `Python 3.9.0` version information, the installation is successful.
Summary In this article, we covered how to install Python 3.9 on Debian. With a few simple steps, you can easily install Python 3.9 and start using this popular programming language. If you run into any issues feel free to ask in the comments below.