Skip to content

Multiple Python Versions on Ubuntu

Ubuntu ships with one Python version per release. The deadsnakes PPA provides additional Python versions as separate packages so multiple versions can coexist. Each version installs as its own binary (python3.9, python3.10, etc.) and can be used to create version pinned virtual environments.

Terminal window
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

Install only the versions actually needed. Each one installs alongside the system Python without replacing it.

Terminal window
sudo apt install python3.9 python3.10 python3.11 python3.12 python3.13

Verify the installed binaries:

Terminal window
ls /usr/bin/python3*

On Ubuntu, the venv module ships in a separate package per version. Install the matching venv package for each Python version that needs to create virtual environments.

Terminal window
sudo apt install python3.9-venv python3.10-venv python3.11-venv python3.12-venv

Call the version specific binary to create the venv. The resulting environment is pinned to that interpreter.

Terminal window
python3.11 -m venv myenv
source myenv/bin/activate
python --version
pip install --upgrade pip