How to Install Python 3.11 on Ubuntu 22.04 LTS
You’ll get a working Python 3.11 binary on Jammy without breaking the system Python that Ubuntu relies on. The steps use the official deadsnakes PPA, so you stay in the apt ecosystem and keep updates automatic.
Add the deadsnakes PPA
Ubuntu 22.04 ships with Python 3.10, so we need a source that provides newer builds.
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
software‑properties-common gives you the add-apt-repository command; without it the PPA addition would fail. Adding the deadsnakes repo tells apt where to fetch 3.11 packages.
Install Python 3.11 and essential tools
sudo apt update
sudo apt install -y python3.11 python3.11-venv python3.11-dev
The python3.11 package is the interpreter, python3.11‑venv lets you create isolated environments, and python3.11‑dev provides header files for compiling C extensions—a must if you ever need to pip install something like NumPy from source.
Verify the installation
python3.11 --version
You should see Python 3.11.x. If you get a “command not found” error, double‑check that the PPA was added correctly and run another apt update.
Optional: Make Python 3.11 the default for new scripts
Ubuntu’s system tools still expect Python 3.10, so don’t replace /usr/bin/python3. Instead, set up an alternative for your user account:
sudo update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.11 110
Now python3 in your shell points to 3.11, but the system Python stays untouched. If anything goes sideways, just remove the alternative with update-alternatives --remove python3 /usr/bin/python3.11.
Real‑world hiccup I’ve seen
After a kernel upgrade, one of my machines refused to start any virtual environment because the old python3-venv package was still linked to Python 3.10. Installing python3.11-venv from deadsnakes fixed it instantly—no need to reinstall the whole OS.
Quick tip: Skip pyenv unless you juggle many versions
I’ve tried pyenv on Ubuntu, and for a single version upgrade it’s overkill. The PPA does the job cleanly and keeps everything in apt’s hands, which is exactly what most everyday users want.