How to Install Python 3.11 on Linux Mint 21 | 20

Python 3.11 release promises up to 60% speed improvements in some instances, which is a significant jump from the 25% improvement in the standard benchmark suite of Python 3.10. In the following tutorial, you will learn how to install Python 3.11 on Linux Mint 21 and 20, given both are LTS releases based on Ubuntu using the command terminal, and how to download and compile as an alternative method.

Recommended Steps Before Installation

Before proceeding with the tutorial, ensuring your system is up-to-date with all existing packages is good.

sudo apt update

Optionally, you can list the updates for users who require review or are curious.

sudo apt --list upgradable

Proceed to upgrade any outdated packages using the following command.

sudo apt upgrade

#1st Method – Installing Python 3.11 with PPA (Recommended)

The first and easiest solution for Linux Mint users would be to import the “deadsnakes” team Launchpad PPA. This will always contain the latest updates for Python and all extra packages that may be required.

Importing Python 3.11 Repository

First, install the following packages that are required. These are most likely installed but run the command to be safe.

sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https -y

For users who have not previously imported a GPG key from the Ubuntu keyserver, the command line terminal will often have issues importing GPG keys from LaunchPAD PPAs because the directories are not created. This is an easy fix. Use the following command that will, in turn, generate the directories.

sudo gpg --list-keys

This can be skipped, but if you encounter an issue, just run the command and re-try.

The next task is to import the GPG key needed.

sudo gpg --no-default-keyring --keyring /usr/share/keyrings/deadsnakes.gpg --keyserver --recv-keys F23C5A6CF475977595C89F51BA6932366A755776

Example output:

gpg: key BA6932366A755776: public key "Launchpad PPA for deadsnakes" imported
gpg: Total number processed: 1
gpg:               imported: 1

With the GPG key now imported, you can import the LaunchPAD PPA. Remember, match the command to the version of Linux Mint you are utilizing, or the installation will likely fail with errors.

Linux Mint 21.x Python import command:

echo 'deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] jammy main' | sudo tee -a /etc/apt/sources.list.d/python.list

Linux Mint 20.x Python import command:

echo 'deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] focal main' | sudo tee -a /etc/apt/sources.list.d/python.list

Before you continue, run an APT update to reflect the newly imported PPA.

sudo apt update

Run installation command for Python 3.11

With the 3.11 PPA now imported, you can install Python by executing the following command.

sudo apt install python3.11 -y

Verify the installation and build version using the following command.

python3.11 --version

Example output:

Python 3.11.0

Optionally, you can install the following extras.

3.11 docs for Python 3.11:

sudo apt install python3.11-docs

Debug module for Python 3.11:

sudo apt install python3.11-dbg

Developer (dev) module Python 3.11:

sudo apt install python3.11-dev -y

VENV module for Python 3.11:

sudo apt install python3.11-venv -y

Distutils module for Python 3.11:

sudo apt install python3.11-distutils -y

2to3.11 utility for Python 3.11:

sudo apt install python3.11-lib2to3 -y

DBM.GNU module for Python 3.11:

sudo apt install python3.11-gdbm -y

Tkinter module for Python 3.11:

sudo apt install python3.11-tk -y

Nopie Module for Python 3.11:

sudo apt install python3.11-nopie

Alternatively, to install all extras, run the full installation command.

sudo apt install python3.11-full

Additionally, you can install what is recommended as minimal extensions.

sudo apt install python3.11-minimal

Optional – Enable Nightly Python 3.11 builds

For developers, you may want to utilize the nightly builds to have the latest version. I would only recommend using this if you are utilizing a development environment; most users should use the stable repository.

Given you have already imported the GPG key, you need to import the repository that matches your Linux Mint version; you can import both stable and nightly PPA’s since the latest version available is always chosen, given 3.11 was recently released, the nightly will always be ahead in this case.

Linux Mint 21.x Python nightly import command:

echo 'deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] jammy main' | sudo tee -a /etc/apt/sources.list.d/python-nightly.list

Linux Mint 20.x Python nightly import command:

echo 'deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] focal main' | sudo tee -a /etc/apt/sources.list.d/python-nightly.list

Now run an update in your terminal to reflect adding the nightly repositories.

sudo apt update

From here, if you have already installed packages from the PPA or Ubuntu’s default repository, you can upgrade them or run the installation commands as stated in the tutorial.

#2nd Method – Installing Python 3.11 – Archive Method

Download Python 3.11

First, visit the official download page and grab the latest version, or in most cases, a particular version or build, as the recommended method would be the PPA for users wanting the latest at all times. The following instructions should work on any version since you are compiling it. Once you have copied the link, use the wget command to download the archive.



Extract the Python archive, and remember to change the version number if you downloaded a newer one.

tar -xf Python-3.11.{version}.tar.xz

Now install the dependencies required.

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev pkg-config make -y

Navigate to the directory.

cd Python3.11.{version}/

Now, run the ./configure –enable-optimizations command.

./configure --enable-optimizations --enable-shared

The script performs several checks to ensure your system’s dependencies are present. The ./configure –enable-optimizations will optimize the Python binary by running multiple tests, making the build process slower.

Now that you have built and configured the environment, it is time to compile it with the command make.


A handy trick is to specify the -j <number of cpu> as this can significantly increase compiling speed if you have a powerful server.

For example only:

make -j 6

Once you have finished building, install Python binaries as follows:

sudo make altinstall

Note, it is advised to use the make altinstall command NOT to overwrite the default Python 3 binary system.

Next, you need to configure the dynamic linker run-time bindings with the ldconfig command after the installation.

sudo ldconfig /opt/Python3.11.{version}

Note, do not skip this, or you will face issues. You will also need to replace the path with your directory name and version.

Confirm the build version is installed by running the following command.

python3.11 --version

Example output:

Python 3.11.0

Switch Default Python Versions

You may have a particular one you want as the default for users needing multiple versions of Python on their system. The following steps will show you how to change python versions when you have numerous installed.

First, you must add the symbolic links for every Python version separately. Next to the symlink, you will add the group name python and the option number.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 4
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 5
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 7
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 8

Remember, it does not require you to have all versions listed up; you can copy the entire command, and the versions you have installed will have symlinks created.

Next, list the python versions with the following command.

sudo update-alternatives --config python

Example output:

As mentioned above, the tutorial machine has Python versions 3.11, 3.10, 3.9, 3.8, and 3.7 installed, with 3.11 currently being the default selected version. This can be seen with the version with an Asterix * next to the selection number.

If you want to make, for example, Python 3.9 the default version, you will enter the selection number 5 in this example, and yours will vary, given the number of versions installed, as the selection numbers may change.

If successful, you will get the following output.

update-alternatives: using /usr/bin/python3.9 to provide /usr/bin/python (python) in manual mode

If you relist the alternative options, Python 3.9 is the default version with the Asterix * default sign.

Share to...