Python is most popular programming language. It is used by multiple ways to build different kinds of applications. Python 3.9 is the latest major release of the Python language. It includes many new features such as new dict operators, new str functions, support for IANA time zone, and more. This tutorial describes multiple ways to install Python 3.9 on Debian 10 system.
Install Python 3.9 on Debian with Apt
It’s very simple and straightforward process to install Python 3.9 on Debian using the apt packages manager.
Step 1 – Update packages list
First, update the packages list and install required dependencies:
sudo apt update
sudo apt install software-properties-common
Step 2 – Enable Repository
After that add the deadsnakes PPA to your system’s sources list by typing:
sudo add-apt-repository ppa:deadsnakes/ppa
Hit the Enter
when you get prompt.
Step 3 – Install Python 3.9
Once the repository enabled you can install the Python 3.9 by runnig below command:
sudo apt update
sudo apt install python3.9
Step 4 – Verify Installation
To verify the installation, you would type:
python3.9 --version
Python 3.9.0+
At this stage, the Python 3.9 is installed on your Debian 10 system.
Install Python 3.9 on Debian from Source
You can install the latest version of Python and customize the build options by compiling the Python from source. Below are the steps to install Python 3.9 from Python source:
Step 1 – Install dependencies
You should install the required dependencies to build python. Run the following commands:
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
Step 2 – Download source code
After that download the latest source code from Python download page using wget:
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
Once the download is finished, extract the tarball:
tar -xf Python-3.9.0.tgz
Step 3 – Configure script
Navigate to the Python source directory and execute the configure script. It will do few checks that required dependencies are installed.
cd Python-3.9.0
./configure --enable-optimizations
The --enable-optimizations
option optimizes the Python binary by running multiple tests. This makes the build process slower.
Step 4 – Start build process
You would run the following command to start the build process for python:
make -j 12
For faster build time, modify the -j to correspond to the number of cores in your processor. You can find the number by typing nproc.
Step 5 – Install Python
Once the build process is complete, install the Python binaries by typing:
sudo make altinstall
That’s it. Python 3.9 has been installed from source and ready to be used. Verify the installation by typing:
python3.9 --version
Python 3.9.0+
Conclusion
This tutorial shows you multiple ways to install Python 3.9 on Debian 10 system. You can read here How to use Pip.
If you have any questions or feedback, leave a comment below.