Before installing any software, you need to update the repositories and install the latest versions of the packages.
apt update && sudo apt upgrade -y
Install Python 3.10 from the PPA
To install Python 3.10 on Ubuntu 20.04 using the repository, you need to add the deadsnakes PPA. Indeed, it makes installing Python on Ubuntu very easy and allows you to get constant updates, bug fixes, and security updates.
Install the necessary dependencies to add the repository.
apt install software-properties-common -y
Now let's add the deadsnakes PPA repository:
add-apt-repository ppa:deadsnakes/ppa
Press Enter.

Now that the deadsnakes repository has been added to your Ubuntu system, we can install Python 3.10 with the command below.
apt install python3.10

After installation, check the installed version of Python.
python3.10 --version

Install Python Modules on Ubuntu 20.04
Modules and extensions are useful in Python because they add functionality to it. They can be installed using the Python Package Manager (PIP).
Let's install it:
apt install python3-pip

Now, after installing the package manager, let's install the module we need.
For example, to work with telegrams, install the following module:
pip install python-telegram-bot

In order to check/see which packages are installed locally, we can use the following command:
pip list
Below we can observe the output of the command, and the python-telegram-bot module we installed:
Package | Version |
anyio certifi chardet command-not-found dbus-python distro distro-info h11 httpcore httpx idna language-selector netifaces pip PyGObject pymacaroons PyNaCl python-apt python-telegram-bot PyYAML requests requests-unixsocket rfc3986 setuptools six sniffio ssh-import-id ubuntu-advantage-tools ufw unattended-upgrades urllib3 wheel | 3.6.2 2019.11.28 3.0.4 0.3 1.2.16 1.4.0 0.23ubuntu1 0.14.0 0.16.3 0.23.3 2.8 0.1 0.10.4 20.0.2 3.36.0 0.13.0 1.3.0 2.0.0+ubuntu0.20.4.7 20.0 5.3.1 2.22.0 0.2.0 1.5.0 45.2.0 1.14.0 1.3.0 5.10 27.7 0.36 0.1 1.25.8 |
Now you can deploy your Python application. In the next article, we will look at how to install Python 3.10 on Centos 7.