Python, Nginx, Postgres Setup on Ubuntu

Ubuntu 22.04 is supplied with Python 3.10. In order to install Python 3.10 on older Ubuntu versions (or newer Python versions for Ubuntu 22.04 like Python 3.11 in future) we must add dead-snakes package repository. Also I usually install Postgres database, Nginx webserver as a reverse proxy for Python's gunicorn server and letsencrypt's certbot tool for certificates management.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.10 python3-pip
sudo python3.10 -m pip install --upgrade pip

sudo apt install -y build-essential libssl-dev libffi-dev nginx curl certbot libpq-dev postgresql postgresql-contrib python3-dev python3-pip python3-venv python3-certbot-nginx

Check if installation is successful:

which python3.10
python3.10 -V

You should get something like this in your terminal output:

Python 3.10.6