How To Install Python 3.10 on Debian 11

In this article, we want to teach you How To Install Python 3.10 on Debian 11.

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis.

It is a general-purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems.

Currently, Python 3.10.2 is the newest release of the Python programming language, and it contains many new features and optimizations.

In this guide, you will learn to install Python 3.10.2 on Debian 11.

Steps To Install Python 3.10 on Debian 11

Before you start to install Python 3.10, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Debian 11.

Now you can follow the steps below to set up Python 3.10 on Debian 11.

Set up Python 3.10 on Debian 11

At this step, you will learn to install Python from the source.

First, you need to update your local package index with the following command:

sudo apt update

Then, you need to install the required packages and dependencies on Debian 11 with the command below:

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

Download Python 3.10 Debian

Now download Python 3.10.2 gzipped source code file from the Official Python release with the wget command:

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

Next, extract your downloaded file with the following command:

sudo tar -xvf Python-3.10.2.tgz

To compile Python 3.10 from the source navigate to the uncompressed folder on Debian 11 with the command below:

cd Python-3.10.2

After that, run the configure script as shown below:

./configure --enable-optimizations

This runs multiple tests and takes quite some time.

Then, you need to start the build process with the command below:

make -j 2

The -j option specifies the number of CPU cores. You can check out the number of cores on your Linux system by using the following command:

nproc

This will take some time to complete the build process.

Debian Install python 3.10

When you are done,  run the following command to install Python binaries:

sudo make altinstall

At this point, you can verify your Python 3.10 installation:

python3.10 --version

Access Python 3.10 Shell on Debian 11

At this point, you can access your Python 3.10 shell with the following command:

python3.10

Now you can write a simple program to find the sum of two variables, x, and y to test your program:

x = 35

y = 75

z = x + y

print("Hello, the sum of x and y is", +z)

In your output you will see:

Hello, the sum of x and y is 110

Conclusion

At this point, you learn to install the latest stable Python 3.10 on your Debian server.

Hope you enjoy it.

You may be like these articles:

Install Python 3.10 on Ubuntu 22.04

How To Set up Python 3.10 on Centos 7

How To Install Python 3.10 on Rocky Linux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!