How to Install Python 3.11 on Ubuntu

Deepak Prasad
Tested on Ubuntu 26.04 LTS (Resolute Raccoon)
Package python3.11 3.11.17-1+resolute1 (Deadsnakes on 26.04)
Applies to Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS
Privilege sudo for apt and PPA; normal user for uv, pyenv, and venv
Scope Install Python 3.11 when a project, wheel, or CI image pins 3.11—not when you want the newest CPython. Covers Deadsnakes, uv, and pyenv beside system python3 on jammy, noble, and resolute. For upstream 3.15, use the latest-Python install guide in Related guides.
Related guides Install Python 3.12 on Ubuntu
Install Python 3.15 on Ubuntu
Short on time?Beta Get the gist of this 9-minute read in seconds, then ask follow-up questions

Install Python 3.11 when compatibility requires that minor—not because you want the latest upstream release.

Python 3.11 lifecycle (October 2026):

  • 3.11.17 is a security release—the series is security-fixes-only
  • Regular bugfix releases have ended; security support continues until October 2027
  • Prefer a newer supported feature release for new projects unless an app or dependency pins 3.11

Pick an install path:

            ┌─────────────────────────────────┐
            │ Need Python 3.11 on Ubuntu?     │
            └────────────────┬────────────────┘
                             │
          ┌──────────────────┴──────────────────┐
          ▼                                     ▼
┌─────────────────────────┐     ┌─────────────────────────────┐
│ APT-managed side-by-side│     │ User-level / many versions  │
└────────────┬────────────┘     └──────────────┬──────────────┘
             ▼                        ┌────────┴──────────┐
┌─────────────────────────┐           ▼                   ▼
│ Deadsnakes PPA          │         ┌────┐            ┌───────┐
│ (3.11.x on LTS)         │         │ uv │            │ pyenv │
└─────────────────────────┘         └────┘            └───────┘

Quick answer: Python 3.11 on Ubuntu by release

Pick a path by release:

  • 26.04 / 24.04 — Deadsnakes, uv, or pyenv (no current 3.11 in the standard archive for side-by-side use)
  • 22.04 — older python3.11 from jammy-updates while python3 stays 3.10; use Deadsnakes, uv, or pyenv for a newer 3.11.x release (for example 3.11.17)

Deadsnakes quick path (after add-apt-repository works on your host):

bash
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
apt-cache policy python3.11
sudo apt install python3.11 python3.11-venv
python3.11 --version
python3 --version

Example on Ubuntu 26.04 after Deadsnakes install:

output
Python 3.11.17
Python 3.14.4

python3 stayed on the 3.14 series; only python3.11 picked up 3.11.17.

Create a venv next:

  • Do not use sudo pip on system python3 (PEP 668 applies on current Ubuntu)
  • Use python3.11 -m venv, activate, then python -m pip
bash
python3.11 -m venv ~/venvs/py311
source ~/venvs/py311/bin/activate
python --version
python -m pip install --upgrade pip
python -m pip --version

Python 3.11 availability on Ubuntu 26.04, 24.04, and 22.04

Ubuntu Default python3 3.11 in Ubuntu archive? When you need newer 3.11 patch releases
26.04 LTS 3.14 series No current python3.11 in the standard 26.04 archive Deadsnakes, uv, or pyenv
24.04 LTS 3.12 No Deadsnakes, uv, or pyenv
22.04 LTS 3.10 Yes—older python3.11 in jammy-updates Deadsnakes/uv/pyenv for a newer 3.11.x release

Why install 3.11 at all:

  • 24.04 — default is 3.12; wheels or CI still target 3.11
  • 26.04 — default is 3.14; applications that still require 3.11
  • 22.04 — default is 3.10; install 3.11 when the app requires that specific minor

Confirm your row with check Ubuntu version before changing repositories.


Before you install: keep Ubuntu's system Python unchanged

IMPORTANT
Do not make Python 3.11 Ubuntu's system python3. apt, cloud-init, and many packages expect the release-managed interpreter at /usr/bin/python3.

Do not:

  • Run sudo update-alternatives --config python3 to point system tools at 3.11
  • Replace or symlink over /usr/bin/python3 manually
  • Copy a custom python3.11 binary onto /usr/bin/python3

Do instead:

  • Call python3.11 explicitly, or activate a project venv
  • Leave python3 for Ubuntu-owned packages

Verify system ownership after any install:

bash
readlink -f /usr/bin/python3
python3 --version
python3.11 --version

Expected series (patch numbers vary with updates):

  • 22.04 — python3 → 3.10
  • 24.04 — python3 → 3.12
  • 26.04 — python3 → 3.14

If readlink or dpkg -S shows a custom 3.11 binary owning system python3:

  • Restore Ubuntu's python3 packages—do not keep retargeting alternatives
  • Use the dpkg command to see which package owns the path
bash
dpkg -S "$(readlink -f /usr/bin/python3)"

Install Python 3.11 with Deadsnakes on Ubuntu

Deadsnakes notes:

  • Community-maintained third-party PPA—not Canonical's default archive
  • Convenient for alternate Python versions on jammy, noble, and resolute
  • Installs python3.11 beside system python3, not instead of it
  • Deadsnakes maintainers do not guarantee the same security-update cadence as Ubuntu's official archive—weigh that for production or security-sensitive workloads (PPA overview)

Add the Deadsnakes PPA for Python 3.11 on Ubuntu

Install the helper that provides add-apt-repository, then enable the PPA:

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

Verify the Python 3.11 package source on Ubuntu

Before apt install, confirm which build apt will use—especially on 22.04, where jammy archive and the PPA can both offer python3.11:

bash
apt-cache policy python3.11

When you intend Deadsnakes, confirm:

  • Candidate comes from ppa.launchpadcontent.net/deadsnakes/ppa
  • Suite matches your release (jammy / noble / resolute)
  • On 22.04, archive and PPA can both list python3.11—read the policy output before installing

Example apt-cache policy on Ubuntu 26.04:

output
python3.11:
  Installed: (none)
  Candidate: 3.11.17-1+resolute1
  Version table:
     3.11.17-1+resolute1 500
        500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute/main amd64 Packages

Your Candidate line should name the Deadsnakes PPA; patch numbers update when the PPA ships new builds.

Install Python 3.11 and venv

Minimal install for most projects (apt packages):

bash
sudo apt install python3.11 python3.11-venv

Confirm system python3 did not change:

bash
python3.11 --version
command -v python3.11
python3 --version
command -v python3

Optional development headers

Install headers only when you need them:

  • Install python3.11-dev when compiling C extensions or building against Python headers
  • Skip -dev when you only run apps and install wheels with pip inside a venv
bash
sudo apt install python3.11-dev

Create a Python 3.11 virtual environment

A venv does not install Python 3.11—it isolates packages after python3.11 exists.

bash
python3.11 -m venv ~/venvs/py311-app
source ~/venvs/py311-app/bin/activate

Verify Python and pip inside the venv

Confirm the activated shell uses the venv interpreter—not system python3:

bash
python --version
python -m pip --version

Expected shape:

output
Python 3.11.17
pip ... from .../venvs/py311-app/lib/python3.11/site-packages/pip (python 3.11)

Upgrade pip inside the venv:

bash
python -m pip install --upgrade pip

Package installs on Ubuntu:

  • Do not use sudo pip or pip install --break-system-packages on system python3
  • Install project dependencies only inside the activated venv
  • If bare pip is missing before Python is set up, see pip command not found

Sanity-check common modules (especially after pyenv builds):

bash
python -c "import ssl, sqlite3, bz2, lzma; print('Python 3.11 OK')"

Deactivate with deactivate.


Alternative: Install Python 3.11 with uv

uv fits when you want user-level Python without a PPA:

  • Managed CPython under your account—not /usr/bin/python3
  • Does not replace system python3
  • uv python install 3.11 tracks the latest 3.11 patch uv publishes
Method Best for
Deadsnakes APT-managed, system-wide python3.11 beside Ubuntu's default
uv Fast user-level Python + venvs without a PPA
pyenv Many CPython versions and per-directory switching

Install uv:

bash
curl -LsSf https://astral.sh/uv/install.sh | sh

Install the latest 3.11 patch uv knows about and create a venv:

bash
uv python install 3.11
uv venv --python 3.11 .venv
source .venv/bin/activate
python --version

uv notes:

  • Uses Astral managed builds—not python.org Linux installer tarballs
  • A developer-managed Python installation under your account—not an Ubuntu python3 package

Alternative: Use pyenv for multiple Python versions

pyenv when you juggle many versions:

  • Compiles CPython under ~/.pyenv/versions/ (requires build deps and a compiler)
  • Full install steps: install latest Python on Ubuntu
  • pyenv install 3.11 usually resolves the latest 3.11 patch your python-build plugin knows

After pyenv is installed:

bash
pyenv install 3.11
pyenv local 3.11
python --version
  • /usr/bin/python3 stays on the Ubuntu default; python follows pyenv in that directory
  • Custom tarball builds belong on the latest-Python page—this article focuses on Deadsnakes, uv, and pyenv

Update Python 3.11

Deadsnakes — refresh indexes and upgrade packages when the PPA publishes newer 3.11.x builds:

bash
sudo apt update
sudo apt install python3.11 python3.11-venv

Re-running apt install pulls newer 3.11.x builds when the PPA (or archive) publishes them.

uv — upgrade the managed 3.11 line:

bash
uv python upgrade 3.11

pyenv — install a newer patch (pyenv install 3.11.x) and update .python-version or pyenv local.


Uninstall Python 3.11

Ubuntu 22.04, 24.04, and 26.04

See what is installed and where it came from:

bash
apt-cache policy python3.11
dpkg -l | grep '^ii  python3.11'

On 22.04, read apt-cache policy python3.11 before you remove anything—Ubuntu's jammy-updates build and a Deadsnakes build are different sources. Uninstall only the packages you added, and drop the PPA only if no other Deadsnakes Python versions still need it.

Remove only packages you added (omit python3.11-dev if you never installed it):

bash
sudo apt remove python3.11 python3.11-venv

After apt remove:

  • venv directories (~/venvs/, ./.venv) are not deleted—remove them yourself
  • PPA removal—only when no other Deadsnakes Python packages are still needed (3.12, 3.13, etc.)

To drop the PPA when it is safe:

bash
sudo add-apt-repository --remove ppa:deadsnakes/ppa
sudo apt update

Full removal patterns (pyenv, source, mixed installs): Uninstall Python on Ubuntu.


Troubleshooting Python 3.11 on Ubuntu

Symptom Likely cause Fix
Unable to locate package python3.11 PPA missing, stale indexes, or wrong suite sudo apt update; check apt-cache policy python3.11
Wrong/old 3.11 on 22.04 Ubuntu archive candidate wins over PPA Re-check apt-cache policy; install explicit Deadsnakes version or pin PPA priority
python3.11 -m venv fails python3.11-venv not installed sudo apt install python3.11-venv
pip: command not found No venv active, or pip not on PATH Activate venv; use python -m pip
externally-managed-environment pip install against system python3 Create a 3.11 venv; install packages inside it
python3 still shows 3.12 / 3.14 Expected Use python3.11 or an activated venv
apt errors after “switching” Python System python3 was retargeted Restore Ubuntu python3 packages; do not use update-alternatives on python3
pyenv build missing _ssl / sqlite3 Build dependencies missing Install build deps from latest-Python pyenv section, or use Deadsnakes/uv

Summary: install Python 3.11 on Ubuntu

Install Python 3.11 when an application, wheel, or CI image requires that minor—not for the newest CPython.

  • Lifecycle — security-fixes-only through October 2027
  • 26.04 / 24.04 — Deadsnakes, uv, or pyenv beside the distro default
  • 22.04 — archive python3.11 exists but is old; use Deadsnakes/uv/pyenv for newer 3.11 patch releases on supported LTS versions
  • Safety — never repoint /usr/bin/python3; use python3.11 and venvs with python -m pip
  • Upstream 3.15 — use the latest-Python hub in the intro Related guides

References


Frequently Asked Questions

Why install 3.11 on Ubuntu 24.04 when 3.12 is default?

  • Some apps and wheels target 3.11 only
  • Install python3.11 beside python3—do not downgrade system Python

Does Ubuntu 22.04 ship Python 3.11?

  • 22.04 defaults to Python 3.10 for python3
  • Ubuntu also ships python3.11 in jammy-updates (older than current upstream)
  • For a newer 3.11.x release (for example 3.11.17), use Deadsnakes, uv, or pyenv—and compare each method's update trust model

Should I use Deadsnakes or uv for Python 3.11?

  • Deadsnakes — APT-managed python3.11 system-wide beside Ubuntu's default
  • uv — fast user-level Python and venvs without a PPA
  • pyenv — many versions and per-project switching

Should I make Python 3.11 the default python3 on Ubuntu?

No. Leave Ubuntu's python3 untouched for apt and system tools. Use python3.11 explicitly or a virtual environment for your project.

Finished reading?Beta Get the key takeaways in seconds, then ask follow-up questions
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware.

  • Debian
  • Ubuntu
  • Linux
  • Red Hat Enterprise Linux
  • Shell Script
  • System Administration