The Python team has announced the new release of Python 3.11. At the same time, Python 3.12 development has been started. So as of today, Python 3.11 is the latest version available for installation. This version is loaded with various new features and security upgrades. The Python developer will feel better with this version in terms of error display and debugging etc.

This tutorial will help you to install Python 3.11 on Debian 11 & Debian 10 Linux systems. The tutorial will compile and install Python 3.11 source code on your system.

  • Step by Step Instructiosn to Create Python Virtual Environment
  • Prerequisites

    Log in to your Debian system with a sudo privileged account. Then 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.11 on Debian

    The default Debian package repositories contain the older versions of Python packages. So if the older version fulfills your requirements, you should install that from default repositories. To explore the latest version features, compile and install Python from the source code on the Debian system.

    Use the following step-by-step instructions to install Python 3.11 on your Debian system:

    1. Download Python: Download the Python 3.11 source code from its FTP website.
      wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz 
      
    2. Extract Archive: Once the downloading is finished, extract the archive with the tar command on your system.
      tar xzf Python-3.11.1.tgz 
      
    3. Compiling Python Source: Change to the extracted directory with cd command, then prepare the Python source code for the compilation with ./configure on your system.
      cd Python-3.11.1 
      ./configure --enable-optimizations 
      
    4. Installing Python 3.11: Finally, as the source code is ready to compile, you can use te make command to compile and install Python from the source code on the Debian system. Here altinstall prevents the compiler to override default Python versions.
      make altinstall 
      

    The compilation may take some time depending on system specifications. Wait for the Python installation to complete on your system.

    Check Python Version

    At this stage, you will have the Python 3.11 installed on your Debian 11 and Debian 10 systems. You need to type python3.11 to use this version. For example, to check the Python version, execute:

    python3.11 -V 
    
    Python 3.11.1
    

    To check the version of pip for Python, execute:

    pip3.11 -V 
    
    pip 22.0.4 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
    

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

    Conclusion

    In conclusion, Python is a high-level, general-purpose programming language used for web applications as well as system programming. In this tutorial, you have learned to install Python 3.11 on Debian Linux systems using source code. You can try Python examples via command line.