How to downgrade Python version to 3.8 in Ubuntu 22.04?

Posted under » Ubuntu » Python » Django on 1 Aug 2022

Python ver 3.8 is often used because it supports more Python libraries than the latest version of Python (3.10). For example, Python 3.8 supports Django version 3.1, 3.2, 4.0 and 4.1. Meanwhile Python 3.10 only supports Django 4 and above version.

By default, ubuntu doesn't install any python version. However if you have installed a version, for example 3.10 and want to use 3.8, 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.

The best practice is that you set up different environments for each python version.

You reate a virtual environment for your chosen Python version and with a chosen set of packages.

That way many different python version can co-exist. For eg. Ubuntu 22.04 supports 3.10 and let's say you want to add an older version (LTS 20.04 is 3.8).

You don't have to install the deadsnakes archive because Venv will do it for you.

When you are in the chosen environment, do this to check.

$ python -V // big V

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