The Python development team has released the latest version of Python 3.10. This includes more new features, security patches, and many other improvements. This version includes a new feature that is “Parenthesized context managers”. Using enclosing parentheses for continuation across multiple lines in context managers is now supported. For more details read the complete changelog.

This tutorial will help you with the installation of Python 3.10 on Debian 11/10 Linux systems. The tutorial will compile and install Python 3.10 source code on your system.

Prerequisites

First of all, Log in to your Debian-based system with sudo privileged account access. Open a terminal (CTRL ALT T) and execute the below commands to update packages.

sudo apt update && sudo apt upgrade 

Then install the required packages for the compilation of Python source code.

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

Install Python 3.10 on Debian

The default Debian repositories contain older Python versions only. So this tutorial will use Python source code for installation on Debian 10 system.

Follow the below steps to install Python 3.10 on Debian:

  1. Download Python – You can directory download Python 3.10 source archive from its official site.
    wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz 
    
  2. Extract Archive – After downloading, extract the archive file on your system.
    tar xzf Python-3.10.2.tgz 
    
  3. Compiling Python Source – Change to the extracted directory with cd command, then prepare the Python source code for the compilation on your system.
    cd Python-3.10.2 
    ./configure --enable-optimizations 
    
  4. Install Python 3.10 – Finally, run the following command to complete the Python installation on Debian system. The altinstall prevents the compiler to override default Python versions.
    make altinstall 
    

Wait for the Python installation to complete on your system.

Check Python Version

At this step, you have successfully installed Python 3.9 on Debian 10 system. You need to type python3.9 to use this version. For example, to check the Python version, execute:

python3.10 -V 

Python 3.10.2

This will also install pip for Python 3.10.

pip3.10 -V 

pip 21.2.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)

That’s it, You have successfully installed Python 3.10 on Debian 11 and Debian 10 systems.

Conclusion

In this tutorial, you have learned to install Python 3.10 on Debian Linux systems using source code. You can try Python examples via command line.