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.
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:
- Download Python: Download the Python 3.11 source code from its FTP website.
wget https://www.python.org/ftp/python/3.11.3/Python-3.11.7.tgz
- 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.
cd Python-3.11.7
./configure --enable-optimizations
The
--enable-optimizations
flag 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 -j
with a number specifies the number of cores to use, speeding up the compilation.make -j 4
make altinstall
Replace 4 with the number of CPU cores in your system. Using
altinstall
prevents 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:
python3.11 -V
Python 3.11.7
The compilations process also installed the PIP for your Python. To check the version of pip for Python, execute:
pip3.11 -V
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.
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.
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.
2 Comments
unfortunately debian 11 does not recognize the upgrade to 3.11. python3 –version is still showing the old version 3.9
Try command: `python3.11 -V`