Sep 14, 2023 3 min read

How to Install Python 3.9 on Debian 10

Install Python 3.9 on Debian 10 with our step-by-step tutorial. It is a popular programming language that offers simplicity and versatility.

Install Python 3.9 on Debian 10
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install Python 3.9 on Debian 10, let's briefly understand – What is Python 3.9?

Python 3.9 is a popular programming language that offers simplicity and versatility. Released in October 2020, it introduces new features and improvements for developers. With enhanced performance and a focus on developer productivity, Python 3.9 includes features like dictionary merging and update operators, improved syntax, and optimized performance for common operations.

Its efficient typing system, pattern matching, and new modules make it a powerful tool for various applications. Python 3.9 is widely adopted in industries such as web development, data analysis, and machine learning, making it an essential language for both beginners and experienced programmers.

In this tutorial, we’ll show you how to install Python 3.9 on Debian 10.

Advantages of Python 3.9

  1. Improved Performance: Python 3.9 introduces optimizations that enhance execution speed and memory usage.
  2. Simplified Development: New features like dictionary merge and update operators streamline code and boost productivity.
  3. Enhanced Typing: Python 3.9 offers an efficient typing system, aiding code reliability and maintainability.
  4. Powerful Pattern Matching: The introduction of pattern matching simplifies complex conditional expressions.
  5. Expanded Modules: Python 3.9 includes new modules for more extensive functionality, expanding its areas of application.

Installing Python 3.9 on Debian 10

Installing the most recent Python version and modifying the build settings are both made possible by compiling Python from source code. The apt package-management won't allow you to update your Python installation, however.

It won't take long to build Python 3.9 on Debian, and the procedure is quite simple.

Install the dependencies necessary to build Python:

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

Use wget to obtain the source code for the most recent version from the Python download page:


The gzipped archive should be extracted after the download is finished.

tar -xf Python-3.9.1.tgz

Launch the configure script by going to the Python source directory:

cd Python-3.9.1
./configure --enable-optimizations

The Python binary is optimized by a number of tests when the --enable-optimizations option is used. This slows down the building process.

The script performs a number of tests to ensure that all of your system's dependencies are present:

Start the Python 3.9 build process:

make -j 2

Change the -j to reflect the number of cores in your CPU for a quicker construction time. If you type nproc, the number will appear.

Install the Python binaries when the compilation process is finished by typing:

sudo make altinstall

Because later will replace the system's default python3 binary, we're using altinstall rather than install.

Python 3.9 has been set up and is prepared for usage. To validate it type the following command:

python3.9 --version

The Python version should appear in the output:


Python 3.9.1

FAQs to Install Python 3.9 on Debian 10

Can I have both Python 3.7 and Python 3.9 on Debian 10?

Yes, you can have multiple Python versions. Use update-alternatives to manage different Python versions on Debian 10.

Does Python 3.9 replace the default Python version on Debian 10?

No, Python 3.9 won't replace the default Python 3.x version. It installs alongside the existing version.

How can I verify if Python 3.9 is installed correctly?

After installation, run python3.9 --version to check if Python 3.9 is installed and displaying the correct version.

Can I uninstall Python 3.9 if needed?

Yes, you can uninstall Python 3.9 with sudo apt remove python3.9. However, be cautious as it may affect dependent applications.

How do I set Python 3.9 as the default version on Debian 10?

Use update-alternatives and update-alternatives --config python3 to set Python 3.9 as the default version interactively.

Will installing Python 3.9 affect my existing Python projects?

Installing Python 3.9 shouldn't affect existing projects using other Python versions. However, it's best to test your projects after installation.

Do I need to reinstall Python packages after installing Python 3.9? 

If you installed Python packages using tools such as pip, you may need to reinstall them for Python 3.9. Use pip freeze to generate a list of installed packages, and then reinstall them using pip install -r <path-to-requirements.txt>.


We have shown how to set up Python 3.9 on a Debian 10 machine. Now that you have set up a virtual environment, you can begin working on your Python applications.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.