How to Install Python Ubuntu 22.04

Updated: October 16, 2021

According to Python’s docs, Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built-in data structures, combined with dynamic typing and dynamic binding, make it very attractive for rapid application development and for use as a scripting or glue language to connect existing components. In this tutorial, I will show you how to install Python Ubuntu 22.04.

Prerequisites to install Python Ubuntu?

  • Operating system: Linux - Ubuntu 16.04, 18.04 to 20.10 with 2GB RAM (4GB preferable).
  • You can use a Linux Terminal to run a Linux script.
  • A user account with sudo privileges

Install Python Ubuntu 22.04

Using APT (Easiest)

As we know, APT, or Advanced Package Tool, is the default package manager that you will find on Ubuntu. You can download the Python package from the official Ubuntu repository. Here’s how to do it.

Step 1: Open up your terminal emulator

Firstly, we need to open your Linux terminal to run any command. If you don’t have any terminal, please follow this to install Alacritty Ubuntu

Step 2: Update the latest versions of the packages

Make sure that all your Ubuntu packages can be downloaded and updated to the latest version.

sudo apt-get update

Step 3: Download the latest version of Python

Now you can start the installation of Python 3.9 with the following command.

sudo apt install python

After installing Python 3, don’t forget to check Python’s version to ensure everything is working correctly.

python --version

Suppose you get something like this. It means Python is installed on your Ubuntu.

Python 3.9.7

Using Deadsnakes PPA

Personal Package Archives (PPAs) are software repositories designed for Ubuntu users and are easier to install than other third-party repositories. PPAs are often used to distribute pre-release software so that it can be tested.

Step 1: Install the above-mentioned package on your Ubuntu

Firstly, make sure your Linux machine can use PPAs. If this package is not installed on your Linux, you can install it by running this command:

sudo apt-get install software-properties-common

Step 2: Add the official Deadsnakes PPA

After that, you can now add the Python PPA to your Ubuntu. The system will prompt you to press enter to continue.

sudo add-apt-repository ppa:deadsnakes/ppa

Step 3: Install Python Ubuntu from the added PPA

Now you can start the installation of Python 3 with this command.

sudo apt update
sudo apt install python3

Don’t forget to check the version you installed.

python --version

Install from source code

Although downloading and building the latest version of Python from the official Python website may seem a bit daunting to you at first, it’ll become easier once you know the process.

Step 1: Update your system’s local repository list

First of all, you need to make sure your Ubuntu packages can be downloaded with the latest version. It can be done easily by executing this command.

sudo apt update

Step 2: Install Python dependencies

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

Step 3: Create store folder

We need to create a folder to store the Python Ubuntu file.

mkdir /python && cd /python

Step 4: Download the Python source code


Step 5: Extract the installer

tar –xf Python-3.9.7.tgz

Step 6: Build the package

After extracting the installer, you must build the package from the source code. Running this Ubuntu command.

sudo make install


Programming languages have become important because of the growing demand for developers across industries. The Python language is used in a variety of different sectors, and its applications are enough to demonstrate how powerful it is. It comes preinstalled on almost every Linux system, and it is also available on official distribution repositories. If you still don’t get Python installed on your computer, then you can easily install it by following this guide to install Python Ubuntu 22.04.