How to Install Python 3.9 On Ubuntu 22.04

Python is an interpreted high-level programming language. It is typically utilized in automation, software development, and data science. Furthermore, in recent years, Python has become one of the top programming languages worldwide and is utilized in Machine learning, website development, software testing, and many other processes. The most recent supported version of Python is “3.9”.

In this write-up, we will demonstrate Python 3.9 installation on Ubuntu 22.04:

  • Using PPA repository
  • Using official setup file

Let’s get started!

Method 1: Python 3.9 installation on Ubuntu 22.04 using PPA repository

To install Python 3.9 on the Ubuntu system with the help of the PPA repository, follow the steps listed below.

Step 1: Update system packages

First open the Ubuntu 22.04 terminal using “CTRL+ALT+T” and update the system packages:

$ sudo apt update

Move on to the next step!

Step 2: Install Additional dependencies

Install the required prerequisites utilizing the command below:

Step 3: Adding PPA repository

In the next step, add “deadsnakes” PPA repository into the system. It is the easiest way for Python 3.9 installation:

$ sudo add-apt-repository ppa:deadsnakes/ppa

Let’s move further for Python 3.9 installation.

Step 4: Python 3.9 installation

To install Python 3.9 on Ubuntu 22.04, run the provided command:

$ sudo apt install python3.9 -y

Step 5: Validate Python Version

$ python3.9 --version

As you can see, we have successfully installed Python “3.9.13” on our Ubuntu 22.04 system:

Let’s move towards the second approach to install Python 3.9.

Method 2: Python 3.9 installation on Ubuntu 22.04 using the official setup file

On Ubuntu 22.04, to install Python 3.9 using the official setup file, follow the below-mentioned steps.

Step 1: Install additional dependencies

Install the additional dependencies first by entering the following command:

$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev -y

Continue to get the setup file.

Step 2: Downloading the Python 3.9 setup

In the next step, download the Official Python 3.9 setup file using the “wget” command:

$ wget

Step 3: Unzip Python 3.9 setup file

Unzip the downloaded setup file of Python 3.9:

$ tar -xvf Python-3.9.7.tgz

Move to the “Python-3.9.7/” folder using the “cd” command:

$ cd Python-3.9.7/

Step 4: Run ./configure script

After opening the “Python-3.9.7/” folder, execute the “./configure” script:

$ ./configure --enable-optimizations

Step 5: Process Build compile configurations

Utilize the “make” command to compile and build the configurations:

$ make

Step 6: Python 3 binaries installation

Finally, use the below-provided command to install Python 3 binaries on the Ubuntu 22.04 system:

$ sudo make altinstall

Step 7: Check out Python version

Confirm the Python successful installation by checking its version:

$ python3.9 --version

The following section will show the procedure of removing Python 3.9 from Ubuntu 22.04.

How to remove Python 3.9 from Ubuntu 22.04?

On Ubuntu 22.04, utilize the given command to remove Python 3.9:

$ sudo apt remove python3.9 -y

We have effectively elaborated the methods to install and remove Python 3.9 Ubuntu 22.04.


On Ubuntu 22.04, to install Python 3.9, either use the PPA repository or the official zip setup file. Using the PPA repository is the easiest way to install the latest python version on Ubuntu 22.04. To do so, add the “deadsnakes” PPA repository and install Python 3.9 with the “$ sudo apt install python3.9 -y” command. In the second method, download the official setup file of Python 3.9 and install it. We have demonstrated the procedure of installing and removing Python 3.9 from Ubuntu 22.04.