How to Install Python 3.8 on Linux Mint 21 LTS

Python 3.8 is an LTS release that is currently receiving security-only updates of the Python programming language that is now. It was released on October 14, 2019. Python 3.8 includes several new features and improvements from its predecessor, such as support for assignment expressions, improved type checking, and more.

Some of the Highlights of Python 3.8:

  • Parallel filesystem cache for compiled bytecode
  • Debug builds share ABI as release builds
  • f-strings support a handy = specifier for debugging
  • continue is now legal in finally: blocks
  • on Windows, the default asyncio the event loop is now ProactorEventLoop
  • on macOS, the spawn start method is now used by default in multiprocessing
  • multiprocessing can now use shared memory segments to avoid pickling costs between processes
  • typed_ast is merged back to CPython
  • LOAD_GLOBAL is now 40% faster
  • pickle now uses Protocol 4 by default, improving performance

For the official Python 3.8 rundown notes, visit the official Python webpage What’s New in Python 3.8.

In the following tutorial, you will learn how to download the latest Python 3.8 on Linux Mint 21 LTS using the command terminal and how to download and compile as an alternative method.

Update Linux Mint

Before you begin, run a quick update to ensure your system is up-to-date, avoiding conflicts during the tutorial and good system maintenance.

sudo apt update && sudo apt upgrade

Option 1. Install Python 3.8 – PPA Method (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.

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 gnupg gnupg2 apt-transport-https -y

The next task is to import the GPG key needed for all the repositories. If you have issues importing the GPG key, please see the end section on GPG troubleshooting at the end of the article.

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 with the following command.

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

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

sudo apt install python3.8 -y

Verify the installation and Python 3.8 build version using the following command.

python3.8 --version

Example output:

Python 3.8.14

Optionally, you can install the following extras.

Install development headers for building C extensions:

sudo apt install python3.8-dev -y

Install the standard library (venv) module:

sudo apt install python3.8-venv -y

Install the standard library (distutils) module:

sudo apt install python3.8-distutils -y

Install the (2to3.8) utility as well as the standard library (lib2to3) module:

sudo apt install python3.8-lib2to3 -y

Install the standard library (dbm.gnu) module:

sudo apt install python3.8-gdbm -y

Install the standard library (tkinter) module:

sudo apt install python3.8-tk -y

Option 2. Install Python 3.8 – Manual Method

Download Python 3.8

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 Python 3.8 archive.



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

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

Move Python 3.8 to a proper destination like the /opt/ directory.

sudo mv Python3.8.{version} /opt/

Now install the dependencies required to install Python 3.8.

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 /opt/Python3.8.{version}/

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

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

The script performs several checks to ensure all of 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, the LinuxCapable machine has 6 CPUs, and I can use all six or at least use 4 to 5 to increase speed.

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.8.{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 that Python 3.8 and the build version are installed by running the following command.

python3.8 --version

Example output:$ python3.8 --version
Python 3.8.14

Create a Virtual Environment

Python’s venv module is a virtual environment is Python environment such that the Python interpreter, libraries, and scripts installed into it are isolated from those established in other virtual environments, and (by default) any libraries installed on your operating system, for example, those that are installed on your Linux Mint system to avoid clashing and disturbing your production environments.

Create a quick Python project to ensure that Python 3.8 is installed correctly.

First, create the project directory and navigate to it:

mkdir ~/test_app && cd ~/test_app

Inside the project root directory, run the following command to create a virtual environment for the test name test_app.

python3.8 -m venv test_app_venv

Note users that installed the PPA will need to install the Python 3.8 venv package if it has not already been installed.

sudo apt install python3.8-venv -y

Next, activate the virtual environment as follows.

source test_app_venv/bin/activate

After starting the virtual environment, you will be in the shell prompt terminal. This will show the name of your environment that will be prefixed.


To exit the virtual environment, use the following command:


Install Python PIP with 3.8

Installing PIP using the following APT command should work for all those using the Python PPA repository.

sudo apt install python3-pip

The manual installation method should have attached PIP; if not, it is advised to install PIP by downloading using the wget command.


Next, install the downloaded file.


Note if Python 3.8 is your default version, it is not required to add 3.8 to the command.

Once installed, it is a good idea to check for upgrades.

python3.8 -m pip install --upgrade pip

How to Fix Broken LaunchPAD GPG Import

Users that have installed Linux Mint for the first time or have not imported a GPG key before using the command line terminal will often have issues importing GPG keys from LaunchPAD PPAs due to the directories not being created. This is an easy fix. Use the following command that will, in turn, generate the directories.

sudo gpg --list-keys

Example output:

As mentioned above, the necessary directories have been created. This can be skipped, and use the following GPG import command below. If you have any issues with directories missing for this and any other PPA GPG key in the future, just run the above command.

How to Switch Python Versions in Linux Mint

For users needing multiple versions of Python on their system, you may have a particular one you want as the default. The following steps will show you how to change python versions when you have multiple 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 an Asterix * next to the selection number.

We will make Python 3.8 the default version so that you will enter selection number 4 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.8 to provide /usr/bin/python (python) in manual mode

If you relist the alternative options, 3.8 should be the default Python version.


As mentioned above, Python 3.8 is now the default version, as shown with the Asterix * next to the selection number.

Comments and Conclusion

As of July 2020, the 3.8 series is no longer supported and only receives security updates; users are encouraged to upgrade to newer versions for better features and support. Python 3.8 will continue to be developed until 2024, with maintenance releases every 12 months; however, compared to other versions, it lacks new features or improvements. If you’re starting a new project, it’s recommended that you use one of the more recent versions available to take advantage of all the latest enhancements.

Share to...