How to Install Python 3.8 on Ubuntu 22.04

Sumit Jain
3 min readJan 29, 2023

--

Python, version 3.8, comes with several new features and improvements.

  1. One of the most notable is the inclusion of a parallel filesystem cache for compiled bytecode. This can provide a significant performance boost when working on large projects.
  2. Debug also builds now share ABI as release builds, which should help reduce debug builds’ overall size.
  3. f-strings now support a handy = specifier for debugging. This can be used to insert the value of an expression into the string, making it easier to track down errors.
  4. continue is now legal in finally: blocks that can be useful when dealing with cleanup procedures that may need to be interrupted

In the following tutorial, you will learn how to install Python 3.8 using the command terminal and how to download and compile as an alternative method.

Recommended Steps Before Installation

Before proceeding with the tutorial, it is highly advised to run an update in your terminal to ensure all packages are up-to-date to avoid any conflicts during the installation.

sudo apt update

Install Python 3.8 — LaunchPAD PPA (Recommended)

The first and easiest solution for Ubuntu 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.8 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

Example output:

gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created

The next task is to import the GPG key needed.

sudo gpg --no-default-keyring --keyring /usr/share/keyrings/deadsnakes.gpg 
--keyserver keyserver.ubuntu.com --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.

Import PPA for Ubuntu 22.04 LTS Jammy Jellyfish

echo 'deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] 
https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu 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

Run installation command for Python 3.8

sudo apt install python3.8 -y

Verify the installation and build version using the following command.

python3.8 --version

Example output:

Python 3.8.16

Hooray!! Now you can do amazing things with python

That’s it folks!! If you like it, do shower your support and like this blog.

Cheers!!

--

--