Python, a versatile and popular programming language, is constantly evolving. The release of Python 3.11 brings new features and optimizations. For Debian users, installing the latest Python version from source allows you to enjoy the latest features and improvements. This guide will walk you through the process of installing Python 3.11 on Debian Versions 10, 11, and 12.
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:
- Download Python: Download the Python 3.11 source code from its FTP website.
- Extract Archive: Once the downloading is finished, extract the archive with the tar command on your system.
tar xzf Python-3.11.7.tgz
- Prepare for the Installation: Navigate to the directory containing the extracted files and run the configure script. This script will check your system for all required dependencies and prepare the Python source code for the installation.
--enable-optimizationsflag helps optimize the Python binary by running multiple tests, which might take a bit longer.
- Build and Install: Now, compile the source code and install Python. The make command facilitates this process. Using
make -jwith a number specifies the number of cores to use, speeding up the compilation.
make -j 4
Replace 4 with the number of CPU cores in your system. Using
altinstallprevents replacing the default system Python.
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:
The compilations process also installed the PIP for your Python. To check the version of pip for Python, execute:
pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
That’s it, You have successfully installed Python 3.11 on Debian 12, Debian 11, and Debian 10 systems.
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.
This guide provides a straightforward method for installing the latest Python version on Debian. Always remember to check Python’s official documentation for any new updates or changes in the installation process.