How to Install the Latest Python on Ubuntu Safely

Deepak Prasad
Tested on Ubuntu 26.04 LTS (Resolute Raccoon)
Ubuntu 24.04 (noble) & 22.04 (jammy) — Deadsnakes package names verified
Package python3.15 3.15.0-1+resolute1 (Deadsnakes)
python3 3.14.4 (Ubuntu default on 26.04 lab)
Applies to Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS
Privilege sudo for apt and PPA; normal user for pyenv, uv, and venv work
Scope Install the current upstream stable Python (3.15 at time of writing) beside Ubuntu's system python3, pick a safe install method, create a virtual environment, and avoid breaking apt. Does not replace version-specific walkthroughs—use the Python 3.11–3.15 install guides when an app pins a minor version.
Related guides Install Python 3.15 on Ubuntu
Install Python 3.14 on Ubuntu
Install Python 3.13 on Ubuntu
pip command not found
Uninstall Python on Ubuntu
Python tutorial
Short on time?Beta Get the gist of this 13-minute read in seconds, then ask follow-up questions

Ubuntu pins python3 so apt, cloud-init, and system packages keep a stable interpreter. When sudo apt install python3 is already the newest package but you need a newer line for your own code, that is normal—not a failed upgrade.

Upstream means releases published by the Python project at python.org, not Ubuntu's distro-packaged python3. Python 3.15.0 became the current stable CPython release on October 9, 2026; older guides that still call 3.15 a beta or preview are outdated.

This guide:

  • Installs the latest stable upstream Python (currently 3.15) next to the release default
  • Walks through Deadsnakes, pyenv, uv, and optional source altinstall
  • Shows how to create a venv and use python -m pip without touching /usr/bin/python3

Lab notes:


Quick answer: install the latest Python on Ubuntu

The current upstream stable release is Python 3.15. On Ubuntu LTS:

  • Install with the Deadsnakes PPA, pyenv, or uv—not by replacing /usr/bin/python3
  • After the interpreter exists, create a venv with that versioned binary
  • Use python -m pip only inside the venv (or with the versioned interpreter you chose)

Fastest packaged route: Deadsnakes (versioned apt packages). For per-release candidates, uninstall steps, and 3.15-specific troubleshooting, see Install Python 3.15 on Ubuntu. On a normal development workstation, pyenv or uv is often a better fit when you want the newest upstream Python without tying projects to a PPA.

Package installs below use apt. Refresh indexes before adding packages:

bash
sudo apt update

Install helper tools for the Deadsnakes path:

bash
sudo apt install software-properties-common

Add the PPA and refresh again:

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

Confirm Deadsnakes offers a 3.15 candidate for your suite (jammy, noble, or resolute) before installing:

bash
apt-cache policy python3.15 python3.15-venv

In that output, Candidate is the version APT would install if you ran sudo apt install python3.15 now.

Install Python 3.15 and its venv module:

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

Confirm Ubuntu's default python3 did not change:

bash
python3 --version
python3.15 --version
command -v python3
command -v python3.15

On the 26.04 lab host after Deadsnakes:

output
Python 3.14.4
Python 3.15.0
/usr/bin/python3
/usr/bin/python3.15

Create a project environment (a venv does not download Python—it only isolates packages after you install python3.15):

bash
python3.15 -m venv ~/venvs/latest-py
source ~/venvs/latest-py/bin/activate
python --version
python -m pip install --upgrade pip

For a focused 3.15-only walkthrough (per-release notes, uninstall, and upgrades), see Install Python 3.15 on Ubuntu.


Latest Python vs Ubuntu's system Python

Source What it is Typical use
python3 → /usr/bin/python3 Ubuntu-owned default for the release Leave it for apt and OS tools
python3.15, pyenv, or uv-managed builds Interpreter you add for applications Project development and testing
~/venvs/... or ./.venv Virtual environment pip installs for one project only

Upstream downloads and release notes live on python.org. Ubuntu documents keeping development Python separate from the system install and recommends pyenv for multiple versions in its Python packaging guide.

Current Python versions on Ubuntu 26.04, 24.04, and 22.04

Ubuntu release Default python3 Latest upstream (Oct 2026) Recommended approach
26.04 LTS (resolute) Python 3.14 Python 3.15 Keep 3.14 as system python3; add 3.15 for projects
24.04 LTS (noble) Python 3.12 Python 3.15 Add 3.15 beside system Python
22.04 LTS (jammy) Python 3.10 Python 3.15 Add 3.15 beside system Python

Confirm your release row with check Ubuntu version commands, then compare defaults:

bash
. /etc/os-release && echo "$PRETTY_NAME"
python3 --version
readlink -f /usr/bin/python3

Example on Ubuntu 26.04:

output
Ubuntu 26.04 LTS
Python 3.14.4
/usr/bin/python3.14

Why you should not replace /usr/bin/python3

Ubuntu tools and many .deb packages expect the release default python3. Replacing it breaks:

  • apt and unattended upgrades
  • Services that call /usr/bin/python3 directly
  • .deb packages that declare a python3 dependency

Do not:

  • sudo rm /usr/bin/python3 or symlink another version over it
  • sudo ln -sf /usr/local/bin/python3.15 /usr/bin/python3
  • Run sudo update-alternatives --config python3 to “upgrade” system Python

Safe layout:

              ┌─────────────────────┐
              │   Ubuntu system     │
              └──────────┬──────────┘
                         │
         ┌───────────────┴───────────────┐
         v                               v
┌─────────────────┐           ┌──────────────────┐
│ /usr/bin/python3│           │ python3.15       │
│ DO NOT REPLACE  │           │ (Deadsnakes /    │
│ apt & OS tools  │           │  pyenv / uv)     │
└─────────────────┘           └────────┬─────────┘
                                       v
                              ┌──────────────────┐
                              │  project/.venv/  │
                              │  pip packages    │
                              └──────────────────┘

Choose a safe Python installation method

Method Best for Jump to
Ubuntu APT You only need the default python3 for this release When APT is enough
Deadsnakes PPA Packaged python3.15 (or other minors) beside system python3 Deadsnakes
pyenv Compile and manage multiple interpreter versions per user pyenv
uv Managed CPython distributions plus project/environment tooling uv
Source make altinstall Exact tarball, no PPA—advanced Source build

Trade-offs at a glance:

  • Deadsnakes — versioned .deb packages and commands such as python3.15; tied to a third-party PPA
  • pyenv — compiles interpreters under ~/.pyenv; best when you switch versions often
  • uv — Astral-managed CPython builds and fast venv workflows under your home directory
  • All three leave /usr/bin/python3 alone when you follow this guide

For a normal development workstation, pyenv or uv is a strong default when you primarily need the newest upstream Python. Use Deadsnakes when you specifically want Ubuntu-style versioned packages from apt. Build from source only when you need the exact upstream tarball or custom compile options (see Advanced source build).


When Ubuntu APT is enough

If the default python3 already matches your project, install the distro packages only:

bash
sudo apt update
sudo apt install python3 python3-venv

On 24.04, that is typically Python 3.12; on 26.04, Python 3.14. Use Install Python 3.14 on Ubuntu when you need 3.14 on an older LTS, or Install Python 3.12 on Ubuntu when 3.12 is the target on 22.04 or 26.04.


Install the latest Python with Deadsnakes

A PPA (Personal Package Archive) is an extra APT repository on Launchpad. Deadsnakes uses one to package alternate Python versions Ubuntu does not ship as the release default. It is community-maintained, not part of Ubuntu's official archive—convenient for versioned packages, but security-update timing and repository lifecycle are separate from Canonical's packages.

IMPORTANT
Because Deadsnakes is a third-party PPA, confirm your normal patching process actually updates its packages. Ubuntu release upgrades may disable third-party PPAs—re-check the repository after moving to a new LTS release.

Deadsnakes publishes stable python3.15 builds for jammy, noble, and resolute (including 3.15.0 packages published after the 3.15.0 stable release).

Add the PPA if you have not already:

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

Check the APT candidate before you install (stale prerelease names or a missing suite show up here):

bash
apt-cache policy python3.15 python3.15-venv

In apt-cache policy output, Candidate is the version APT would install if you ran sudo apt install python3.15 now.

Install the interpreter and venv support:

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

Add python3.15-dev only when you compile C/C++ extensions, embed Python, or need development headers—not for a typical venv + pip workflow.

Verify the versioned binary and confirm system python3 is unchanged:

bash
python3.15 --version
command -v python3.15
python3 --version
command -v python3

Sample output on Ubuntu 26.04:

output
Python 3.15.0
/usr/bin/python3.15
Python 3.14.4
/usr/bin/python3

Upgrade patch releases when apt offers them:

bash
sudo apt update
sudo apt install --only-upgrade python3.15 python3.15-venv

For uninstall steps and version-specific troubleshooting, see Install Python 3.15 on Ubuntu and Uninstall Python on Ubuntu.


Install the latest Python with pyenv

pyenv installs interpreters under ~/.pyenv/versions/ and is a good fit when you switch between many minors on one account. Ubuntu's developer documentation describes pyenv for managing multiple versions without touching system Python.

Install build dependencies once (or run upstream pyenv install-prerequisites on supported distros if you prefer pyenv's maintained list):

bash
sudo apt update
sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev \
  libreadline-dev libsqlite3-dev curl git libncursesw5-dev xz-utils tk-dev \
  libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Install pyenv (official installer):

bash
curl -fsSL https://pyenv.run | bash

Add pyenv to your shell (bash example—restart the shell or source ~/.bashrc afterward):

bash
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Install and select Python 3.15 for the current directory:

bash
pyenv install 3.15.0
pyenv local 3.15.0
python --version
command -v python

python should resolve through ~/.pyenv/shims while /usr/bin/python3 stays on the Ubuntu default.

Create a venv with the pyenv-selected interpreter:

bash
python -m venv .venv
source .venv/bin/activate
python -m pip --version

For many versions on one machine, see also Install Python 3.13 on Ubuntu and sibling guides when you pin older lines.


Optional: Install the latest Python with uv

uv installs managed CPython builds under your user data directory (not /usr/bin). It is a fast option when you want upstream builds without compiling and without adding a PPA.

Install uv:

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

Install Python 3.15:

bash
uv python install 3.15
uv python list

uv notes:

  • Python.org does not publish official Linux binary distributions; uv uses Astral-managed standalone CPython builds
  • Fits developer workstations, not replacing Ubuntu's python3 package

Create a venv with uv:

bash
uv venv --python 3.15 .venv
source .venv/bin/activate
python --version

Advanced: Build the latest Python from source safely

Use a source build when you need the exact python.org tarball and neither Deadsnakes nor uv fits. Install build libraries that match the modules you plan to import—missing -dev packages often surface as failed import lzma or import ssl after compile.

Install build dependencies aligned with Python's build guidance:

bash
sudo apt update
sudo apt install build-essential pkg-config curl \
  zlib1g-dev libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev \
  liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev \
  libssl-dev tk-dev uuid-dev

Download the current 3.15.x tarball (adjust the version if a newer patch is current). Optionally verify the archive against the SHA-256 sum on the python.org release page before building. The download uses curl and tar:

bash
cd /tmp
curl -fsSLO https://www.python.org/ftp/python/3.15.0/Python-3.15.0.tgz
tar -xf Python-3.15.0.tgz
cd Python-3.15.0

Configure with a dedicated prefix so files stay out of Ubuntu's python3, then use make altinstall so the build installs a versioned python3.15 under that prefix—not a generic python3 that could shadow other interpreters:

bash
./configure --prefix=/opt/python-3.15
make -j"$(nproc)"
sudo make altinstall

Verify:

bash
/opt/python-3.15/bin/python3.15 --version
python3 --version

System python3 must still report the Ubuntu default. Add /opt/python-3.15/bin to your PATH only when you intend to use that build. When 3.15 is the target, Install Python 3.15 on Ubuntu covers Deadsnakes-centric upgrade and removal paths in more detail.


Create a virtual environment with the new Python

A virtual environment does not install another Python. It only isolates packages after python3.15 (or another interpreter) exists.

Install the matching -venv package when you used Deadsnakes:

bash
sudo apt install python3.15-venv

Create and activate an environment:

bash
python3.15 -m venv ~/venvs/myproject
source ~/venvs/myproject/bin/activate
python --version

Prove SSL, SQLite, and common extension modules work:

bash
python -m pip install --upgrade pip
python -c "import ssl, sqlite3, bz2, lzma; print('Python environment OK')"

Sample on the 26.04 lab:

output
Python 3.15.0
Python environment OK

Install packages only inside the venv:

bash
python -m pip install requests

If python3 -m pip install on system python3 fails with externally-managed-environment, that is PEP 668 protecting Ubuntu's interpreter—use a venv instead of sudo pip. See pip command not found when pip itself is missing.

Deactivate with deactivate. For packaging workflows, see create a Python package.


Update and uninstall alternate Python on Ubuntu

How you installed Update Remove
Deadsnakes sudo apt update && sudo apt install --only-upgrade python3.15 python3.15-venv sudo apt remove python3.15 python3.15-venv (do not remove system python3)
pyenv pyenv install newer patch, pyenv local pyenv uninstall 3.15.0
uv uv python install 3.15 again uv python uninstall 3.15
/opt/python-3.15 source Rebuild from newer tarball into same prefix Remove the prefix directory

Never purge Ubuntu's python3 metapackage or the release-owned Python interpreter to “remove Python.”


Troubleshooting latest Python installs on Ubuntu

Symptom Likely cause Fix
python3 still shows an old version Expected—new install is versioned Use python3.15 or a venv
python3.15: command not found Package not installed or wrong series Add Deadsnakes PPA, sudo apt update, install python3.15
Unable to locate package python3.15 PPA missing, stale cache, or no candidate apt-cache policy python3.15; re-add PPA and sudo apt update
import lzma / import ssl fails after source build Missing -dev library at compile time Install the matching dev package, wipe the build tree, reconfigure, rebuild
externally-managed-environment pip on system python3 python3.15 -m venv then python -m pip inside
pip targets wrong Python Multiple installs on PATH python -m pip from the intended interpreter
ensurepip / venv errors Missing -venv package sudo apt install python3.15-venv
System Python changed after experiments Symlink or update-alternatives Restore Ubuntu python3 packages; do not repoint /usr/bin/python3

Summary: install the latest Python on Ubuntu

Ubuntu keeps a stable python3 per release while upstream CPython advances—3.15 is the current stable line at time of writing.

  • Install 3.15 beside system Python with Deadsnakes, pyenv, or uv
  • Reserve source altinstall or a dedicated /opt prefix for advanced cases
  • Never replace /usr/bin/python3 or use update-alternatives to “upgrade” Ubuntu's Python

After python3.15 exists:

  • Create a venv with python3.15 -m venv (a venv isolates packages; it does not download Python)
  • Install dependencies with python -m pip inside that environment
  • For web apps, continue with Install Flask on Ubuntu using the same venv pattern

When an application pins an older minor, use the matching install guide linked earlier in this page (3.11, 3.12, 3.13, or 3.14).


References


Frequently Asked Questions

What is the latest Python version?

Upstream stable CPython is 3.15.0 as of October 2026. Ubuntu LTS releases ship an older default python3 for stability—install 3.15 beside it when your own projects need the newest line.

What Python does Ubuntu 26.04 use?

The default python3 package targets Python 3.14. You can install 3.15 from Deadsnakes or pyenv without changing /usr/bin/python3.

What Python does Ubuntu 24.04 use?

Python 3.12 is the typical default. Install 3.15 or another minor from Deadsnakes when applications require it.

Is it safe to upgrade Python on Ubuntu?

Safe for your projects means adding a new interpreter and moving work into a venv. It is not safe to replace system python3 or run sudo pip against it.

Should I use Deadsnakes, pyenv, or uv?

Deadsnakes fits when you want versioned apt packages such as python3.15. pyenv fits when you compile and switch among many versions per directory. uv fits when you want managed CPython plus fast project venvs without a PPA.

Does a virtual environment install another Python version?

No. A venv reuses whichever interpreter you pass to -m venv (for example python3.15). Install that binary first, then create the environment.

Can Python 3.15 and Ubuntu's Python exist together?

Yes. Expect python3 to stay on the Ubuntu default and python3.15 (or pyenv shims) for application work.

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