In this short article we will learn how to install Python 3.9 on Ubuntu 22.04 Linux operating system. We will use Python 3.9.16 source to be installed on our tutorial. The Python 3.9.16 is the latest stable version which was released on 16 December 2022.
Python is an interpreted high-level general-purpose programming language. Python has become one of the famous programming languages worldwide and it has been utilized in Machine learning, website development, software testing, and many other processes. The most recent adopted version of Python is 3.9.x.
Installing Python 3.9.16 On Ubuntu 22.04
There are several ways to install Python 3.9 on the Ubuntu 22.04 operating system, namely:
- Installing Python 3.9 on Ubuntu 22.04 using using PPA repository
- install Python 3.9 on Ubuntu 22.04 from source
On this tutorial we will use installing Python using PPA repository.
Prerequisites
Before we are going to the installation process we have to prepare the environment first as mentioned below :
- Ubuntu 22.04 System with updated repository
- root or an ordinary account with sudo privilege
- Sufficient disk space and good internet access
The Python 3.9 installation on Ubuntu 22.04 will be consist of several steps, namely :
- Update Ubuntu 22.04 system
- Install Additional dependencies packages
- Adding PPA repository
- Install Python 3.9
- Verify Python 3.9 installation
The detailed explanation of each item will be in the following sub-chapters
1. Update Ubuntu 22.04 system
The first step of Python 3.9 installation is to update local packages software. This task will cut down the installation time and it also helps prevent zero-day exploits against outdated software. We will use command line :
$ sudo apt update $ sudo apt upgrade
2. Install Additional Dependencies Packages
In this step, we will install software-properties-common package.
$ sudo apt install software-properties-common
Output :
ramans@infodiginet:~$ sudo apt install software-properties-common Reading package lists... Done Building dependency tree... Done Reading state information... Done software-properties-common is already the newest version (0.99.22.3). software-properties-common set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
3. Adding PPA Repository
In this stage, we will add PPA deadsnakes repository. We will add ppa:deadsnakes repository by submitting command line :
$ sudo add-apt-repository ppa:deadsnakes/ppa=
Output :
ramans@infodiginet:~$ sudo add-apt-repository ppa:deadsnakes/ppa
Repository: 'deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main'
Description:
This PPA contains more recent Python versions packaged for Ubuntu.
Disclaimer: there's no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.
4. Installing Python 3.9
The next step is to insall Python 3.9 on Ubuntu 22.04 LTS operating system. For this purpose we will submit the following command line :
$ sudo apt install python3.9
Output :
ramans@infodiginet:~$ sudo apt install python3.9 Reading package lists... Done Building dependency tree... Done 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 binfmt-support The following NEW packages will be installed: libpython3.9-minimal libpython3.9-stdlib python3.9 python3.9-minimal 0 upgraded, 4 newly installed, 0 to remove and 4 not upgraded. Need to get 5.243 kB of archives. After this operation, 19,3 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 libpython3.9-minimal amd64 3.9.16-1+jammy1 [834 kB] Get:2 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.9-minimal amd64 3.9.16-1+jammy1 [2.073 kB] Get:3 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 libpython3.9-stdlib amd64 3.9.16-1+jammy1 [1.841 kB] Get:4 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.9 amd64 3.9.16-1+jammy1 [495 kB] Fetched 5.243 kB in 36s (147 kB/s) Selecting previously unselected package libpython3.9-minimal:amd64. (Reading database ... 268367 files and directories currently installed.) Preparing to unpack .../libpython3.9-minimal_3.9.16-1+jammy1_amd64.deb ... Unpacking libpython3.9-minimal:amd64 (3.9.16-1+jammy1) ... Selecting previously unselected package python3.9-minimal. Preparing to unpack .../python3.9-minimal_3.9.16-1+jammy1_amd64.deb ... Unpacking python3.9-minimal (3.9.16-1+jammy1) ... Selecting previously unselected package libpython3.9-stdlib:amd64. Preparing to unpack .../libpython3.9-stdlib_3.9.16-1+jammy1_amd64.deb ... Unpacking libpython3.9-stdlib:amd64 (3.9.16-1+jammy1) ... Selecting previously unselected package python3.9. Preparing to unpack .../python3.9_3.9.16-1+jammy1_amd64.deb ... Unpacking python3.9 (3.9.16-1+jammy1) ... Setting up libpython3.9-minimal:amd64 (3.9.16-1+jammy1) ... Setting up python3.9-minimal (3.9.16-1+jammy1) ... Setting up libpython3.9-stdlib:amd64 (3.9.16-1+jammy1) ... Setting up python3.9 (3.9.16-1+jammy1) ... Processing triggers for gnome-menus (3.36.0-1ubuntu3) ... Processing triggers for man-db (2.10.2-1) ... Processing triggers for mailcap (3.70+nmu1ubuntu1) ... Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
5. Verify Python 3.9 installation
After installation is completed done, then we will verify the Python 3.9 version by issuing command line :
$ python3.9 --version
Output :
ramans@infodiginet:~$ python3.9 --version Python 3.9.16
From the output above, we have installed the latest Python, version 3.9.16 successfully.
Conclusion
In this short tutorial , we have learned how to install Python 3.9.16 on Ubuntu 22.04 by using PPA repository successfully. I hope this tutorial will be helpful.