How to Install Python 3.9 on Ubuntu 20.04

In this article, we are going to install Python 3.9 on Ubuntu 20.04 via Apt and we will use deadsnakes repository.

Installing Python 3.9 on Ubuntu via Apt

First, check for any pending system updates,

apt update

apt upgrade

Install required packages.

apt install software-properties-common

Add deadsnakes repository to your system.

add-apt-repository ppa:deadsnakes/ppa

Install Python 3.9 on Ubuntu.

apt install python3.9

Output:

[email protected]:~# apt install python3.9
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib python3.9-minimal
Suggested packages:
  python3.9-venv python3.9-doc binutils binfmt-support
The following NEW packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib python3.9 python3.9-minimal

To check Python version.

python3.9 --version

Output:

[email protected]:~# python3.9 --version
Python 3.9.0+