How can we help?
Categories
< All Topics
Print

Installing Python 3.7-3.9 on Ubuntu 22.04 Jammy LTS using PPA

Canonical recently announced the general availability of Ubuntu 22.04 Jammy Jellyfish LTS on April 21, 2022. Jammy has Python 3.10 installed already. Indeed, you can install more versions via the upstream repository, but it only provides Python 2.7 and Python 3.10 modules. In this article, I will show you how to install Python 3.7 up to 3.9

TLDR

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install python3.8

Installing Python

First of all, you’ll need the following package installed so we can import any PPA (Personal Package Archive) repositories:

sudo apt install software-properties-common -y

Then, we will import deadsnake’s PPA:

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

You can then install previous Python versions, for example, Python 3.7:

sudo apt install python3.7

The maintainer of the PPA informs that they only ship Python 3.7 as the lowest version for Jammy, so if you wish to install the older version, you might want to install it for source.

Supported Ubuntu and Python Versions
====================================

- Ubuntu 18.04 (bionic) Python2.3 - Python 2.6, Python 3.1 - Python 3.5, Python3.7 - Python3.11
- Ubuntu 20.04 (focal) Python3.5 - Python3.7, Python3.9 - Python3.11
- Ubuntu 22.04 (jammy) Python3.7 - Python3.9, Python3.11
- Note: Python2.7 (all), Python 3.6 (bionic), Python 3.8 (focal), Python 3.10 (jammy) are not provided by deadsnakes as upstream ubuntu provides those packages.

Install PIP

The previous python installation does not provide pip by default, so you will have to do:

python3.x -m ensurepip --upgrade

Then verify it using

pip --version

Important Thing to Note

Never change the default Python version of Ubuntu, as it will break many things. Either by changing python3 symlink or using update-alternatives command.

Conclusion

To summarize the article, it is easy to install previous versions of Python on Ubuntu 22.04 Jammy LTS thanks to deadsnake team’s PPA. Hopefully, you find this tutorial article helpful for your present and upcoming projects.

For more articles and tutorials about technology, please visit ServerStadium’s Knowledge Base 

Table of Contents