How to Install Python 3.9 on Debian 11

Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation.

First, check for any pending system updates,

apt update

apt upgrade

Install required packages.

apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Install Python 3.9 on Debian

By default, Debian 11 bullseye comes with Python version 3.9.2 only. In this article, we are going to install Python 3.9.6 on Debian 11 system.

Download Latest Version of Python 3.9 source archive from its official website.

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

Extract the downloaded file.

tar xzf Python-3.9.6.tgz 

Change to the extracted directory with following command.

cd Python-3.9.6 

Run configuration command.

./configure --enable-optimizations 

Complete the Python installation on Debian system by running the following command.

make altinstall 

To check Python version.

python3 --version

Output:

root@server:~# python3 --version
Python 3.9.6

Using pip on Python 3.9

Check the installed version of a pip by running the following command,

pip3.9 -V

Output:

root@server:~# pip3.9 -V
pip 21.1.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)