How to Install Python on Debian 11

In this tutorial, you will learn how to install Python on Debian 11 Bullseye. One option is to install from the Debian repository with apt command, or we can manually install the latest official release of Python from We’ll cover both methods below.

Install From Debian Repo

This is the easiest method, but you won’t always get the absolute latest Python release:

$ sudo apt update
$ sudo apt install python

Install Latest Version From Official Download

The next method takes a few additional steps, but ensures that you download and install the absolute latest Python release.

Step 1. Before installing Python, always make sure that you have your system up to date:

$ sudo apt update
$ sudo apt upgrade

Step 2. Next, we’ll install the dependencies:

$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev

Step 3. Navigate to the Python download page and choose from either the latest stable release or pre-release version. Download either the compressed gzipped tarball, or the xz tarball.

Step 4. Extract the downloaded file with tar command:

$ cd ~/Downloads
$ tar -xf Python-*

Step 5. Change into the directory where the Python source was extracted:

$ cd Python*/

Step 6. Optimize the Python build process by executing:

$ ./configure --enable-optimizations

Step 7. Once done, we build the Python source with the make command followed by the -j parameter and the number of cores that you have in your system. You can check this by running the nproc command.

$ make -j 2

Step 8. Finally, proceed to install Python:

$ sudo make altinstall

Note: the altinstall option is necessary to ensure that the system-default Python files won’t be touched.

Step 9. To verify that the installation was successful, execute the following command and you should see the expected version number:

$ python3.11 --version

Note: Replace 3.11 with the version number that you installed.

2 thoughts on “How to Install Python on Debian 11”

  1. This was my first visit to this website. What a surprise to find simple, easy-to-follow, instructions! I always remember build-essential but the other dependencies seem to get lost over time. I’m glad someone writes them down.

Leave a Comment

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