For this tutorial, we will install Python 3.10 from the deadsnakes PPA.
sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.10 python3.10-dev python3.10-venv
# To check if the install is successful
python3.10 --version
If you get this error ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/init.py)
, that means you need to re-install pip that matched the new python
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
[…] Install Python3.10 on Ubuntu 22.04|20.04|18.04 […]