Oct 11, 2023 5 min read

How to Install Python 3.9 on Debian 11

Install python 3.9 on Debian 11 with our step-by-step tutorial. It is the latest major release of the Python programming language.

Install Python 3.9 on Debian 11
Table of Contents

Choose a different version or distribution

Introduction

Before we start talking on how to install Python 3.9 on Debian 11, let's briefly understand - What is Python?

Regardless of your level of programming experience, you must be familiar with Python. One of the most well-liked and potent programming languages is Python. It is a free, open-source language that may be used by novices as well as corporations.

Python 3.9 is the latest major release of the Python programming language, offering new features and improvements.

Installing Python 3.9 on Debian 11 allows you to take advantage of these enhancements and develop applications using the latest version of Python.

In this tutorial, you will install Python 3.9 on Debian 11. We will also address a few FAQs on how to install Python 3.9 on Debian 11.

Advantages of Installing Python 3.9 on Debian 11

  1. New Features and Enhancements: Python 3.9 introduces new features and enhancements that improve the language and make programming more convenient and efficient. These advancements include the walrus operator, improved type hints, enhanced string formatting, and more.
  2. Optimized Performance: Python 3.9 includes performance optimizations that can result in faster execution times for certain operations. These optimizations help optimize code execution and improve overall performance for Python applications.
  3. Compatibility with Libraries and Frameworks: Many libraries and frameworks are continually updated to support the latest version of Python. By installing Python 3.9 on Debian 11, you can take advantage of these updates and ensure compatibility with the latest versions of popular Python packages.
  4. Ecosystem Support: The Python community is active and vibrant, offering a vast ecosystem of libraries, frameworks, and tools. By installing Python 3.9 on Debian 11, you can access the most recent developments in the Python ecosystem, enabling you to leverage cutting-edge technologies and integrations.
  5. Long-Term Support (LTS): Python 3.9 has been designated as a stable release and will receive long-term support from the Python community. This ensures that critical bug fixes and security updates will be available, giving you a reliable and supported Python runtime environment.

Installing Python 3.9 in Debian 11

Updating the apt cache index is the first step in installing Python 3.9 in our Debian 11 system. To accomplish this, issue the below given command:

sudo apt update

Type the following command if there are any packages that need to be upgraded:

sudo apt upgrade

However, as you can see, all the packages in my instance are up to current, so it wasn't necessary.

We've upgraded our system successfully; let's restart it with the following command:

sudo reboot

The process of installing Python 3.9 will now be initiated. We need to install the dependent packages in order to achieve this. Use the command as follows:

sudo apt install wget software-properties-common build-essential libnss3-dev zlib1g-dev libgdbm-dev libncurses5-dev   libssl-dev libffi-dev libreadline-dev libsqlite3-dev libbz2-dev

The following step is to go to the official Python website and download version 3.9 from there. It can be found through the subsequent link:

https://www.python.org/downloads/

After that, enter the following command while changing the version:

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

After that, we have to extract the downloaded file. It can be extracted using the command below:

tar xvf Python-3.9.6.tgz

Let's switch to the working directory after the downloaded file has been successfully extracted. It's for making a Python folder. First, we use the command below to change the directory:

We shall then execute the configuration command. In order to accomplish this, enter the following command into your terminal:

 ./configure --enable-optimizations

The Python build procedure will now be started as the following step. In order to accomplish this, enter the following command into your Terminal:

sudo make altinstall

After running the above-mentioned command, your output should appear as follows if Python was successfully installed:

At the end of the output from that previous command, you will see the following message:

Type the next command to check the installation:

python3.9 --version

The following link allows us to install the Python modules as well:

https://pypi.org/

Click the aforementioned link, then use the following command to install any desired modules:

python3.9 -m pip install <moduleName>

Since everything is finished now, let's just use Python 3.9. The following command should be used to use the Python 3.9 shell:

 python3.9

We will now create our first Python 3.9 program in Debian 11. Everyone is aware of the first program a programmer ever wrote, which printed "Hello World." Just print "hello world" for now.  Fill in the following:

>>> print("Hello World!")

Type the following command to end or quit the Python shell session:

>>> exit()

FAQs on Installing Python 3.9 on Debian 11

Why should I install Python 3.9 instead of using the default Python version on Debian 11? 

Although Debian 11 may come with an older version of Python pre-installed, installing Python 3.9 provides access to new features and improvements.

What are the prerequisites for installing Python 3.9 on Debian 11? 

To install Python 3.9 on Debian 11, you need to have administrative access to the system. You also need a network connection to download the necessary packages during the installation process.

How can I add the deadsnakes PPA to Debian 11?

To add the deadsnakes PPA to Debian 11, you can use the add-apt-repository command, followed by updating the package lists with apt update.

Can I have multiple Python versions installed on Debian 11 simultaneously? 

Yes, it is possible to have multiple Python versions installed on Debian 11. By default, each Python version will have its separate installation and can be accessed via the corresponding version-specific executable.

How do I verify if Python 3.9 is installed correctly on Debian 11? 

You can verify if Python 3.9 is installed correctly on Debian 11 by running the command python3.9 --version. It should display the version number of Python 3.9.

Can I install Python packages and modules using pip with Python 3.9 on Debian 11? 

Yes, after installing Python 3.9 on Debian 11, you can use pip to install Python packages and modules specifically for Python 3.9. Ensure that you have the appropriate version of pip installed.

Can I still use older Python versions alongside Python 3.9 on Debian 11? 

Yes, you can have multiple Python versions coexist on Debian 11. Each version will have its specific installation and can be accessed independently. This allows you to use different versions depending on your requirements.

Conclusion

One of the most well-known languages in computer science is Python. Every developer has worked in this language at some point. Rightfully so! Because it provides a vast array of areas. In this language, we may create both Web applications and machine learning algorithms.

To install Python 3.9 on Debian 11, we've walked you through each and every step, including examples. We even ran a basic hello world program in Python 3.9 shell as an example to get you started.

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 Tutorials - 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.