How to install Python 3.11.4 on Debian 11 bullseye

Published July 05, 2023

How to install Python 3.11.4 on Debian 11

The latest version of Python is 3.11.4. I use Debian 11 for a lot of my work , and would like to have the latest Python 3.11.4. Unfortunately, Debian 11 stable includes a much older version. This tutorial will help you install Python 3.11.4 on Debian 11.

Linode

I use Linode for my web hosting. It is an awesome hosting company. I use the unmanaged plan, so that means I get to install Nginx, configure the system and install the latest and greatest version of Python, which is 3.11.4.

Go get your Linode account with $100 free credits for 60 days.

Install Python using apt

The default version of Python on Debian 11 is Python 3.9.2. If you are happy with it, good.

$ apt info python3
Package: python3
Version: 3.9.2-3
Priority: optional
Section: python
Source: python3-defaults
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 91.1 kB
Provides: python3-profiler
Pre-Depends: python3-minimal (= 3.9.2-3)
Depends: python3.9 (>= 3.9.2-0~), libpython3-stdlib (= 3.9.2-3)
Suggests: python3-doc (>= 3.9.2-3), python3-tk (>= 3.9.2-0~), python3-venv (>= 3.9.2-3)
Replaces: python3-minimal (<< 3.1.2-2)
Homepage: https://www.python.org/
Tag: devel::interpreter, devel::lang:python, devel::library,
 implemented-in::c, implemented-in::python, role::devel-lib,
 role::program, role::shared-lib
Cnf-Extra-Commands: python
Cnf-Priority-Bonus: 5
Download-Size: 37.9 kB
APT-Manual-Installed: no
APT-Sources: http://deb.debian.org/debian bullseye/main amd64 Packages
Description: interactive high-level object-oriented language (default python3 version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python 3 version (currently v3.9).

If you want to upgrade to 3.11.4, read on.

Download Python 3.11.4 source

Python 3.11.4 was released on June 6, 2023. The latest Python source code is available here.

Download and extract the Python source code.

cd /tmp/
wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz
tar -xzvf Python-3.11.4.tgz
cd Python-3.11.4/

Install the build tools

Now, install the build tools. The build tools includes gcc, make, zlib, ssl libraries and other libraries.

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev

If you are prompted to install other dependencies, select yes.

Configure, make and make install

./configure --enable-optimizations

Now run make. You can make the build using nproc, which returns the number of CPUs.

make -j `nproc`

Make install

The default Python installation is /usr/bin. If you want to install Python under /usr/local/bin instead of overwriting the default, do this:

sudo make altinstall

This will install Python at /usr/local/bin/python3.11. To test the version, run this:

python3.11 -V

You will get this output:

Python 3.11.4

Make Python 3.11.4 the default version

To make the default version of Python 3.11.4, run this:

sudo ln -s /usr/local/bin/python3.11 /usr/local/bin/python

This creates a bunch of softlinks and links the latest Python to /usr/local/bin.

Test whether Python 3.11.4 is the default version:

$ ls -al /usr/local/bin/python
lrwxrwxrwx 1 root root 25 Jul  5 19:33 /usr/local/bin/python -> /usr/local/bin/python3.11

$ /usr/local/bin/python3.11 -V
Python 3.11.4
python -VV

The output will be:

Python 3.11.4 (main, Jul  5 2023, 19:29:26) [GCC 10.2.1 20210110]

So, at this point, Python 3.11.4 has been set as the default version of Python.

Hope this worked for you. If you have any issues installing Python on your Debian 11 system, feel free to contact me.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: July 05, 2023.     This post was originally written on January 26, 2023.