Posted under » Ubuntu » Python » Django updated on 1 Aug 2025
Python ver 3.10 is often used because it supports more Python libraries than the latest version of Python (3.12). For example, Python 3.12 supports Django version 4.0 and 5.1. Meanwhile Python 3.10 only supports Django 4 and above version.
Ubuntu will install the `latest' Python version because some things like apt-get uses Python. If you have for example 3.12 and want to use 3.10, 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.
The Deadsnakes PPA is a repository that provides newer or older Python versions not available in the official Ubuntu repositories. We add it to our sources list with:
$ add-apt-repository ppa:deadsnakes/ppa $ apt install python3.10 $ apt install -y python3-pip
Run the following update-alternatives commands to enable multiple versions in your Python binary /usr/bin/ location. Replace python3.12 with your active Python version and python3.10 with the newly installed version.
$ update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 $ update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
View all available Python versions you can switch between on your server.
$ update-alternatives --config python3 Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.10 2 auto mode 1 /usr/bin/python3.12 1 manual mode 2 /usr/bin/python3.10 2 manual mode Press <enter> to keep the current choice[*], or type selection number:
You reate a virtual environment for your chosen Python version and with a chosen set of packages.
Take note that things that is not the default version only work only in that venv.. so you have to create a screen while running the app
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).
When you are in the chosen environment, do this to check.
$ python3 --version