How to install Python 3.10 on Debian 11

how to install python 3.10 on debian 11

Python is one of the most widely used open-source, multipurpose, and object-oriented programming languages. It is gaining popularity due to its simplicity and easy-to-use syntax. It is a high-level language and is generally used in web development, gaming development, data analytics and visualization, AI, and machine learning.

At the time of writing this tutorial, Python 3.10 is the latest stable version and was released on October 04, 2021. Python 3.10 comes with some cool features including, Structural Pattern Matching, Improved Error Reporting, Security Updates, Pattern Matching, and more.

In this post, we will show you how to install Python 3.10 on Debian 11.

Prerequisites

  • A Debian 11 VPS with root access enabled or a user with sudo privileges.

Log in via SSH and Update your System

First, you will need to log in to your Debian 11 VPS via SSH as the root user:

ssh root@IP_ADDRESS -p PORT_NUMBER
Next, run the following commands to upgrade all installed packages on your VPS:

apt-get update -y

Once all the packages are updated, restart your system to apply the changes.

Install Required Dependencies

By default, Python 3.10 is not included in the Debian 11 default repository. So you will need to install essential packages for downloading and compiling Python 3.10 from the source.

You can install all the required dependencies using the following command:

apt-get install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -y

After installing all the required dependencies, you can move forward to download the Python 3.10 source.

Download Python 3.10

You can download the Python 3.10 source either by going to the Python download page and downloading the tarball via your web browser or you can use the wget command to download it via command-line interface:

wget -c https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz

Once the download is completed, extract the downloaded tarball using the following command:

tar -Jxvf Python-3.10.0.tar.xz

Once the Python source is extracted, you can proceed to the next step.

Install Python 3.10

Now, navigate to the extracted directory using the following command:

cd Python-3.10.0

Next, start the compilation using the following command:

./configure --enable-optimizations

After the successful compilation, you will get the following output:

checking for --disable-test-modules... no
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile

Finally, build and install Python 3.10 into /usr/local/bin directory without replacing the older Python version:

make altinstall

Verify Python 3.10 Installation

At this point, Python 3.10 is installed on your system. You can now verify it using the following command:

python3.10 --version

You will get the Python version in the following output:

Python 3.10.0

By default, Python 3.9 is set as a default version in Debian 11. It is recommended to set Python 3.10 as a default version.

You can set Python 3.10 as a default version using the following command:

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

You can also set Pip3.10 as a default version using the following command:

update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1

Now, run the following command to check the default Python version:

python --version

You will get the following output:

Python 3.10.0

Of course, if you are one of our Debian Hosting customers, you don’t have to install Python 3.10 on your Debian 11 VPS – simply ask our admins, sit back, and relax. Our admins will install Python 3.10 on Debian 11 for you immediately.

PS. If you liked this post about how to install Python 3.10 on Debian 11 VPS, please share it with your friends on the social networks using the buttons below, or simply leave a comment in the comments section. Thanks.

Leave a Comment

To prove you are human please solve the following *