How to Install Python 3.9 on Debian 11

On this short article we will learn how to install Python 3.9 on Debia 11 operating system.


Python is an interpreted high-level general-purpose programming language. Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects. On this article we will install Python 3.9 on Debian 11 operating system.
Python 3.9 Installation

On this tutorial we install Python 3.9 on Debian 11, the installation will be consist of several steps, namely:

  • Install Required Dependencies Packages
  • Download Python 3.9
  • Build and Install Python 3.9
  • Verify Python 3.9


Before we are going to the installation process we have to prepare the environment first as mentioned below :

  • Debian 11 System with updated repository
  • root or ordinary account with sudo privilege
  • Sufficient disk space and good internet access

Install Required Dependencies Packages

The first step is to install the essential dependencies required for building Python 3.9. For this purpose we will submit the command line :

$ sudo apt update -y
$ sudo apt upgrade -y
$ sudo apt install wget build-essential libreadline-dev
$ sudo apt install libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev
$ sudo apt install libc6-dev libbz2-dev libffi-dev zlib1g-dev -y

Download Python 3.9

On this step, we will download Python 3.9 source from Python Official website. For this purpose we will use wget command line.

$ wget

The output is as shown :

ramansah@otodiginet:~$ wget
--2021-12-23 12:09:29--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25787134 (25M) [application/octet-stream]
Saving to: ‘Python-3.9.9.tgz’

Python-3.9.9.tgz 100%[=====================================>] 24.59M 149KB/s in 2m 8s

2021-12-23 12:11:40 (197 KB/s) - ‘Python-3.9.9.tgz’ saved [25787134/25787134]

After download is completed, then extract it by using tar command line.

$ tar xvf Python-3.9.9.tgz

Build and Install Python 3.9

After extracting the Python 3.9 tarbal file, the we will build and install it by using command line :

$ cd Python-3.9.9
$ ./configure --enable-optimizations

The output is as shown below :

ramansah@otodiginet:~$ cd Python-3.9.9

ramansah@otodiginet:~/Python-3.9.9$ ./configure --enable-optimizations
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.9... python3.9
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for a sed that does not truncate output... /usr/bin/sed
checking for --with-cxx-main=<compiler>... no
checking for g++... no

By default, distutils will build C++ extension modules with "g++".
If this is not intended, then set CXX on the configure command line.

Then we will make the file by using command line :

$ sudo make altinstall

Then verify the Python installation by querying its version. We will submit the command line :

$ python3.9 --version
Python 3.9.9


On this short article, we have tried to install Python 3.9 on Debian 11 operating system.

Add a Comment

Your email address will not be published. Required fields are marked *