How to downgrade Python version in Ubuntu 22.04?

Posted under » Ubuntu » Python on 1 Aug 2022

Do not downgrade the system version: it's likely that some parts of the system would stop working. Never change /usr/bin/python3, and avoid putting an older version of python3 before it in the $PATH.

What you need to do is add another version of Python to the one that exist in 22.04, which is 3.10. Let's say you want to add an older version (LTS 20.04 is 3.8).

The deadsnakes archive provides packages of most supported Python versions for currently supported Ubuntu LTS versions. To make these packages available, follow the usual instructions to enable a PPA. Then install the package(s) you want.

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8

Different versions of Python can co-exist. To check if the version was indeed installed.

$ python3.8 -V

You can then create a virtual environment for your chosen Python version and with a chosen set of packages.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS IOT