Guides 11792 Published by

The guide explains how to add the deadsnakes PPA to Ubuntu 22.04, install Python 3.11 alongside its development headers and venv package, and verify that the new interpreter works without disturbing the system‑default Python 3.10. It then shows an optional update-alternatives command that lets a regular user make python3 resolve to the newly installed 3.11 binary while keeping Ubuntu’s core scripts safe. A short troubleshooting note warns that after kernel upgrades you may need to reinstall python3.11‑venv if virtual environments break, and it advises against using pyenv for a single version upgrade. By staying within apt’s ecosystem, the method ensures automatic updates and avoids the complexity of manual source builds.



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.