Install Python 3.9 or 3.8 on Ubuntu 22.04 LTS Jammy JellyFish

Learn how to use the PPA repository to install Python’s old versions such as 3.9. 3.8, 3.7, and more on Ubuntu 22.04 Jammy JellyFish using the command terminal. 

Python is freely available for the common operating systems. The programming language is standard equipment in many Linux distributions. Python can also be used on many mobile operating systems. For web servers, WSGI (Web Server Gateway Interface) is a universal interface between the server and Python.

It offers clear syntax and good readability. It is considered easy to learn and can be interpreted in the common operating systems. Python supports several programming paradigms such as functional, object-oriented, or aspect-oriented programming, and can also be used as a scripting language.

Since Python is a so-called multiparadigm language, programmers are not tied to a specific programming style. The optimal programming style can be selected for the various tasks. Python allows Python programs to be embedded in other languages ​​as individual modules.

Steps to install Python 3.9 or 3.8 on Ubuntu 22.04 LTS

There are many scenarios when we especially the developers need to have an old Python version to work with some particular application or on the project. In this tutorial, we learn how to get that…

1. Start with the system update

Execute the system update command to ensure our Ubuntu 22.04 has the latest security and package versions. Open your terminal and run:

sudo apt update && sudo apt upgrade

 

2. Add PPA for Python old versions

The old versions of Python such as 3.9, 3.8, 3.7, and older are not available to install using the default system repository of Ubuntu 22.04 LTS Jammy JellyFish or 20.04 Focal Fossa. Hence, we need to add a PPA offered by the “deadsnakes” team to get the old archived Python versions easily.

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa

 

3. Check the Python Versions you want

Once you have added the PPA repository, we can install most of the old Python versions with just one command. To confirm whether the version you want is available to install or not, you can run:

sudo apt-cache policy python(version)

Example:

sudo apt-cache policy python3.9

Add PPA for Python old versions

 

4. Install Python 3.9 on Ubuntu 22.04

Well, once you have confirmed the version you want of Python is available to install using the added repository, next use the given command syntax to install it.

For example, if you want to install version 3.9

sudo apt install python3.9

Install python3.9 on Ubuntu 22.04

 

5. Install Python 3.8 on Ubuntu

The way we have installed version 3.9 using the PPA, we can go for the 3.8 as well.

sudo apt install python3.8

Install Python 3.8 on Ubuntu 22.04 Jammy

In the same way, we can install Python in other versions such as 3.7, 3.6, and more…

 

6. Set the default Python version

If you have installed multiple versions of Python and want to set any of them as the default version of the system then that can be possible as well. For example, you have the latest version of Python 3.10 (was while doing this article) and also have installed python 3.9 and 3.8; now to set any of them are system’s default use Update-alternatives command:

Check what Python versions are available on your systems:

ls /usr/bin/python*

Check what python versions are available on Ubuntu

To know whether any version is configured as Python alternatives or not. For that run:

sudo update-alternatives --list python

If the output is:

“update-alternatives: error: no alternatives for python”

Then it means there are no alternatives that have been configured, hence let’s do some.

Here we are setting up two versions as alternatives, later we will be able to choose between them to set one of them as the system’s default one.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 3

 

Switch the default Python version 

sudo update-alternatives --config python

This time you will see several options including Python 3.9 and 3.8. Enter the Selection number of the Python you want to set as the system’s default one. For example, here Python3.9 is at number 3, hence we type that and Enter key.

sudo update alternatives config python

When you check the version of Python this time, you will have 3.9. For that use:

python -V

 

7. Uninstall Python and PPA

Those who don’t want the installed Python version on the system and also want to remove the PPA if doesn’t require any more, use the given commands.

sudo apt remove --purge python3.9

In the same way for 3.8:

sudo apt remove --purge python3.8

To remove PPA:

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

 

Other Articles:

5 Redhat enterprise-based alternatives for CentOS 8
Install Python 3.x or 2.7 on Debian 11 Bullseye Linux
6 Best Ubuntu Linux Alternatives for Beginners to use in 2022
Ubuntu 22.10 Kinetic Kudu – Daily Build ISO Download

 

 

2 thoughts on “Install Python 3.9 or 3.8 on Ubuntu 22.04 LTS Jammy JellyFish”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.