How to Install Python 3.9 on Debian 10

how to install python 3.9 on debian 10

Python is a free, open-source, and high-level programming language used for scripting and automation. It is very popular, object-oriented, and used by many top tech companies including Google. It is known for its simplicity and easy-to-use syntax.

The Python 3.9 version has been released with new features/modules, security updates, and improvements. In this post, we will show you how to install Python 3.9 on Debian 10 VPS.

Prerequisites

  • A Debian 10 VPS (we’ll be using our SSD 2 VPS plan)
  • Access to the root user account (or access to an admin account with root privileges)

Log in to the Server & Update the Server OS Packages

First, log in to your Debian 10 server via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.

Before starting, you have to make sure that all Debian OS packages installed on the server are up to date. You can do this by running the following commands:

apt-get update -y
apt-get upgrade -y

Install Required Dependencies

Next, you will need to install some required dependencies in order to compile Python from the source. You can install all the required dependencies using the following command:

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

After installing all the dependencies, you can proceed to install Python 3.9.

Install Python 3.9

By default, Python version 3.9 is not included in the Debian 10 default repository. So you will need to compile it from the source.

First, download the Python 3.9 source using the following command:

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

Once the download is completed, extract the downloaded file with the following command:

tar -xvzf Python-3.9.5.tgz

Next, change the directory to the extracted directory and configure it with the following command:

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

Now, build Python 3.9 using the following command:

make -j 2

Note: Replace 2 with the number of cores in your processor.

Once the build process has been completed, install the Python using the following command:

make altinstall

Once Python3.9 has been installed, you can verify the Python version with the following command:

python3.9 --version

You should get the following output:

Python 3.9.5

You can set the Python 3.9 as the default version by running the following command:

update-alternatives --install /usr/bin/python python /usr/local/bin/python3.9 1

Output:

update-alternatives: using /usr/local/bin/python3.9 to provide /usr/bin/python (python) in auto mode

Now, verify the default Python version with the following command:

python --version

You should see the following output:

Python 3.9.5

Congratulations! you have successfully installed Python 3.9 on Debian 10.

Of course, you don’t have to install Python 3.9 if you use one of our Managed Debian VPS Hosting services, in which case you can simply ask our expert Linux admins to install Python 3.9 on Debian 10, for you. They are available 24×7 and will take care of your request immediately.

how to set up python 3.9 on debian 10

Finally, if you liked this post on how to install Python 3.9 on Debian 10, please share it with your friends on social networks using the buttons on the left, or simply show your appreciation by commenting below.

Leave a Comment

To prove you are human please solve the following *