This tutorial shows how to install and setup the Python programming language 3.10 in Debian 11 bullseye.
Python 3.10 is the latest version of the interpreted high-level general-purpose programming language released a few days ago. It features pattern matching, writing union types as X | Y, OpenSSL 1.1.1, and more. And it has 18-month support with bug-fix updates, and 5-year support with security updates.
Unlike Fedora and Ubuntu, there’s neither official package nor PPA repository that contains Python 3.10 package for Debian users. However, compiling Python from source is easy and here’s how!
Build Python 3.10 in Debian 11:
Firstly, open terminal from start menu or connect to Debian Server command console. Next run following commands one by one to build Python 3.10 either in Debian 11 Desktop and/or Server.
1. Install Dependencies:
In terminal or command console, first update system package by running command:
sudo apt update
Next install essential packages for downloading the source and building the program:
sudo apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
2. Download Python 3.10:
Then download the source tarball either by running the wget command:
wget -c https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz
Or, going to the this web page and download the tarball via your web browser.
After that, extract the source tarball either via file manager or using command:
tar -Jxvf Python-3.10.0.tar.xz
3. Build Python 3.10:
After downloading and extracting the source tarball, navigate to the generated source folder via cd command:
And configure with expensive, stable optimizations (PGO, etc.):
Finally, build and install Python 3.10 into /usr/local/bin directory without overriding the current Python 3.9 installation:
sudo make altinstall
Depends on your CPU, you may specify how many threads to start, e.g., -j4 for 4 threads. So the command could be
sudo make install -j4
4. Verify Python 3.10 installation:
After installation, verify it via command:
Set Python 3.10 as default in Debian 11:
Debian 11 by default uses python 3.9 as default for python3 executable and leave ‘python’ un-configured. Users may link Python3.10 to python easily via update-alternatives command:
1.) Set Python3.10 as python via command:
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1
2.) Set Pip3.10 as pip via command:
sudo update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1
After that, run
python --version and
pip --version to check results.
As you see, it’s quite easy to compile Python 3.10 from source tarball. Just install dependencies, download source and build it. And it installs in a few minutes in my case with no error occurred. As well, users may set Python 3.10 and Pip 3.10 as default easily by creating symbolic links using update-alternatives command.