Updated 31 Oct 2023 for Python 3.12
Ubuntu 22.04 is supplied with Python 3.10. In order to install Python 3.12 (or newer Python versions) 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.12 python3-pip sudo apt install python3.12-distutils sudo python3.12 -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.12 python3.12 -V
You should get something like this in your terminal output:
Python 3.12.0