Python 3.15 lets Ubuntu developers test the next CPython branch before it becomes the default in future distributions. To install Python 3.15 on Ubuntu safely, keep it beside Ubuntu’s package-owned interpreter and use versioned commands, virtual environments, or a separate source-build prefix instead of changing /usr/bin/python3.
Python 3.15 is still a prerelease branch. The current official release used here is Python 3.15.0b1, released on May 7, 2026, and PEP 790 schedules the final Python 3.15.0 release for October 1, 2026. Use this branch for compatibility testing, early migration work, and free-threaded runtime experiments unless your deployment policy allows prerelease interpreters.
Install Python 3.15 on Ubuntu
Choose a Python 3.15 Installation Method on Ubuntu
Ubuntu does not use Python 3.15 as the default system interpreter. The practical choices are the Deadsnakes PPA for packaged preview builds or a Python.org source build when you need the exact current upstream prerelease. Both methods keep Python 3.15 separate from the system runtime.
| Method | Channel | Current 3.15 State | Updates | Best For |
|---|---|---|---|---|
| Deadsnakes PPA | Launchpad PPA | Preview packages for Ubuntu 26.04, 24.04, and 22.04; newer releases can lag Python.org | APT-managed package updates | Side-by-side testing with packaged python3.15, venv, dev, and nogil packages |
| Source compilation | Python.org source | Exact Python 3.15.0b1 source archive with Sigstore and SHA-256 checks | update-python315 helper rebuilds when newer 3.15 source releases appear | Exact upstream beta, custom prefixes, or custom build flags |
Protect Ubuntu’s Default Python Before Installing Python 3.15
Ubuntu tools depend on the default python3 runtime shipped by that Ubuntu release. Replacing /usr/bin/python3, registering a new default with update-alternatives, or copying Python 3.15 over the system interpreter can break apt helpers, add-apt-repository, command-not-found, cloud-init, desktop update tools, maintainer scripts, and OS automation that expects Ubuntu’s ABI and module set.
- Ubuntu 26.04 uses Python 3.14 by default: Keep
/usr/bin/python3managed by Ubuntu, and run preview Python 3.15 withpython3.15or a virtual environment. - Ubuntu 24.04 uses Python 3.12 by default: Deadsnakes Python 3.15 packages install beside the system runtime.
- Ubuntu 22.04 uses Python 3.10 by default: Keep project packages in Python 3.15 virtual environments, not in the system Python site-packages directory.
- Source builds need their own prefix: Use
make altinstallwith a prefix such as/usr/local/python3.15. Do not install a custom build into/usr.
If a tutorial tells you to make Python 3.15 the default
python3on Ubuntu, skip that step. Versioned commands, virtual environments, shell aliases, project shebangs, and service files give you Python 3.15 where you need it without taking ownership of Ubuntu’s system runtime.
Update Ubuntu Before Installing Python 3.15
Refresh package indexes before adding a PPA or installing build dependencies:
sudo apt update
Reading package lists... Done
Apply available updates when the system has pending security or base-library changes:
sudo apt upgrade
Most installation and removal commands need administrative privileges. If your account cannot use
sudo, switch to a suitable administrator account or follow how to add a new user to sudoers on Ubuntu.
Install Python 3.15 with Deadsnakes PPA
The Deadsnakes PPA is the easiest packaged route for Python 3.15 on Ubuntu 26.04, 24.04, and 22.04. It installs a versioned python3.15 interpreter and optional companion packages without replacing Ubuntu’s default python3.
Install the helper package for add-apt-repository:
sudo apt install software-properties-common
Add the Deadsnakes PPA and refresh package lists:
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt update
Check the available Python 3.15 packages before installing. Ubuntu 26.04 currently has an earlier PPA preview than Ubuntu 24.04 and 22.04, so use the source-build method when you need the exact Python.org beta.
apt-cache policy python3.15 python3.15-venv python3.15-dev python3.15-nogil
python3.15:
Installed: (none)
Candidate: 3.15.0~a8-1+resolute1
Version table:
3.15.0~a8-1+resolute1 500
500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute/main amd64 Packages
python3.15-venv:
Installed: (none)
Candidate: 3.15.0~a8-1+resolute1
Version table:
3.15.0~a8-1+resolute1 500
500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute/main amd64 Packages
python3.15-dev:
Installed: (none)
Candidate: 3.15.0~a8-1+resolute1
Version table:
3.15.0~a8-1+resolute1 500
500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute/main amd64 Packages
python3.15-nogil:
Installed: (none)
Candidate: 3.15.0~a8-1+resolute1
Version table:
3.15.0~a8-1+resolute1 500
500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute/main amd64 Packages
The exact package revision changes as the PPA maintainers publish new prereleases. Ubuntu 24.04 and 22.04 currently show 3.15.0~b1 packages, while Ubuntu 26.04 currently shows 3.15.0~a8. If your release still shows an earlier alpha candidate while Python.org lists a newer beta, use the source-build path when you need the exact upstream prerelease.
Install the interpreter, venv module, and development headers:
sudo apt install python3.15 python3.15-venv python3.15-dev
Verify the packaged interpreter and core extension modules:
python3.15 --version
python3.15 -c "import ssl, sqlite3, bz2, compression.zstd; print('Python 3.15 modules ready')"
Python 3.15.0a8 Python 3.15 modules ready
Install the Python 3.15 Free-Threaded Package
The PPA also publishes a python3.15-nogil package for the free-threaded build. Use it for research, benchmark work, or library compatibility checks tied to PEP 703, not as a drop-in replacement for every workload.
sudo apt install python3.15-nogil
Verify that the free-threaded interpreter runs with the GIL disabled:
python3.15t --version
python3.15t -c "import sys; print('GIL disabled:', not sys._is_gil_enabled())"
Python 3.15.0a8 GIL disabled: True
Compile Python 3.15 from Source on Ubuntu
Source compilation is the best route when you need the exact Python.org prerelease, a predictable prefix, or custom build flags. This path keeps the interpreter under /usr/local/python3.15 and uses make altinstall, so it does not overwrite Ubuntu’s default Python.
Download and Verify Python 3.15 Source
Install download, archive, and verification tools first. The python3-venv package lets you run the Sigstore verifier in an isolated temporary environment instead of installing verifier packages into Ubuntu’s system Python.
sudo apt install curl ca-certificates xz-utils python3-venv
Create a workspace and download the official Python 3.15.0b1 archive plus its Sigstore bundle. Check the Python.org release page for a newer archive, signer, and checksum when another beta or release candidate appears.
mkdir -p "$HOME/python3.15-source-build"
cd "$HOME/python3.15-source-build"
PY315_VERSION="3.15.0b1"
PY315_ARCHIVE="Python-${PY315_VERSION}.tar.xz"
PY315_URL="https://www.python.org/ftp/python/3.15.0/${PY315_ARCHIVE}"
PY315_SHA256="d4d52ccfa1d727ef5235fbb7d70fa1dbacf10b8b3760db622875da05acbe437c"
curl -fLO "$PY315_URL"
curl -fLO "${PY315_URL}.sigstore"
printf '%s %s\n' "$PY315_SHA256" "$PY315_ARCHIVE" | sha256sum -c -
Python-3.15.0b1.tar.xz: OK
Verify the Sigstore bundle for the same archive. Python 3.15.0b1 is signed with the hugo@python.org identity through GitHub’s OIDC issuer, matching the release-manager identity for this prerelease. Python’s Sigstore metadata notes explain the release-asset verification format.
python3 -m venv "$HOME/python3.15-source-build/sigstore-venv"
"$HOME/python3.15-source-build/sigstore-venv/bin/python" -m pip install --quiet --upgrade pip sigstore
"$HOME/python3.15-source-build/sigstore-venv/bin/python" -m sigstore verify identity --bundle "${PY315_ARCHIVE}.sigstore" --cert-identity hugo@python.org --cert-oidc-issuer https://github.com/login/oauth "$PY315_ARCHIVE"
OK: Python-3.15.0b1.tar.xz
Extract the verified archive in the same terminal session so the variables above remain available:
tar -xf "$PY315_ARCHIVE"
cd "Python-${PY315_VERSION}"
Install Python 3.15 Build Dependencies
Install the compiler, headers, and libraries needed for a useful CPython build. The shared dependency set includes libzstd-dev so the Python 3.15 compression.zstd module builds correctly.
sudo apt install build-essential zlib1g-dev libncurses-dev libgdbm-dev libgdbm-compat-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev libbz2-dev liblzma-dev uuid-dev libexpat1-dev tk-dev pkg-config make libzstd-dev
Install libmpdec-dev when APT offers it. Ubuntu 22.04 packages it in main, and Ubuntu 26.04 currently packages it in universe; enable Ubuntu’s Universe repository first if a minimal 26.04 system cannot locate it. Ubuntu 24.04 does not currently publish this development package, so source builds there can skip the C _decimal accelerator unless you provide mpdecimal separately. Use the Deadsnakes PPA path when you need a packaged Python 3.15 build with that module on Ubuntu 24.04.
if apt-cache show libmpdec-dev >/dev/null 2>&1; then
sudo apt install libmpdec-dev
else
echo "libmpdec-dev is not available from the enabled Ubuntu sources"
fi
Configure and Build Python 3.15
Configure Python with ensurepip enabled and a dedicated prefix, then compile and install it with altinstall:
./configure --with-ensurepip=install --prefix=/usr/local/python3.15
make -j"$(nproc)"
sudo make altinstall
The install target places the interpreter at /usr/local/python3.15/bin/python3.15. It does not create or replace /usr/bin/python3.
Verify the Source-Built Python 3.15 Interpreter
Confirm the interpreter version and standard-library extension modules that the shared dependency set should provide:
/usr/local/python3.15/bin/python3.15 --version
/usr/local/python3.15/bin/python3.15 -c "import ssl, sqlite3, bz2, compression.zstd; print('Source build core modules ready')"
Python 3.15.0b1 Source build core modules ready
When libmpdec-dev was installed before the build, verify the C decimal accelerator separately:
/usr/local/python3.15/bin/python3.15 -c "import _decimal; print('Source build _decimal accelerator ready')"
Source build _decimal accelerator ready
Create a source-built virtual environment and verify pip:
/usr/local/python3.15/bin/python3.15 -m venv "$HOME/venvs/py315-source"
"$HOME/venvs/py315-source/bin/python" -m pip --version
pip 26.1.1 from /home/ubuntu/venvs/py315-source/lib/python3.15/site-packages/pip (python 3.15)
Use Python 3.15 Virtual Environments on Ubuntu
Virtual environments are the safest way to use Python 3.15 packages on Ubuntu. They keep prerelease project dependencies away from Ubuntu’s package-managed Python and avoid the need for --break-system-packages. For a broader walkthrough, see how to create a Python virtual environment on Ubuntu.
Create and activate a venv from the Deadsnakes package:
python3.15 -m venv "$HOME/venvs/py315"
source "$HOME/venvs/py315/bin/activate"
Create and activate a venv from the source-built interpreter:
/usr/local/python3.15/bin/python3.15 -m venv "$HOME/venvs/py315-source"
source "$HOME/venvs/py315-source/bin/activate"
Upgrade packaging tools inside the active environment, install project dependencies, and check dependency consistency:
python -m pip install --upgrade pip setuptools wheel
python -m pip install package-name
python -m pip check
Ubuntu’s package-managed Python environments follow the externally managed environment model, so do not force global package installs into the system interpreter. Use venvs for Python 3.15 projects, and see how to install pip on Ubuntu when you need pip basics for other Python versions.
Deactivate the environment when you finish working in that project:
deactivate
Troubleshoot Python 3.15 on Ubuntu
Fix Unable to Locate Package python3.15
This error usually means the Deadsnakes PPA was not added, package lists are stale, or the Ubuntu release is not one of the packaged targets.
E: Unable to locate package python3.15
Recheck the PPA and candidate package:
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt update
apt-cache policy python3.15
Handle a Lagging Python 3.15 PPA Candidate
Preview packages can lag the official Python.org release page for a short period, especially on a newer Ubuntu release. If apt-cache policy python3.15 still shows an alpha build but the official release page shows a beta or release candidate, either wait for the PPA package to catch up or compile Python 3.15 from source with the verified Sigstore bundle and checksum.
Repair System Tools After Changing python3
If APT helpers, cloud-init hooks, update tools, or Python-based system utilities break after a manual Python change, check where /usr/bin/python3 points:
readlink -f /usr/bin/python3
python3 --version
/usr/bin/python3.12 Python 3.12.3
Ubuntu 26.04 should report Python 3.14, Ubuntu 24.04 should report Python 3.12, and Ubuntu 22.04 should report Python 3.10. Reinstall Ubuntu’s package-owned runtime components if the symlink or core modules were changed.
sudo apt install --reinstall python3-minimal python3-apt python3-distro-info
Do not fix system breakage by pointing
/usr/bin/python3at Python 3.15. Restore Ubuntu’s packaged runtime, then usepython3.15or a venv for projects that need the prerelease interpreter.
Fix ensurepip or venv Errors
If the PPA interpreter cannot create a venv, install the matching venv package and recreate the environment:
sudo apt install python3.15-venv
rm -rf "$HOME/venvs/py315"
python3.15 -m venv "$HOME/venvs/py315"
For source builds, rebuild with --with-ensurepip=install if python3.15 -m ensurepip is unavailable.
Fix Missing Modules After a Source Build
Missing modules such as ssl, sqlite3, bz2, or compression.zstd usually mean a development library was missing during configure. Install the relevant dependency packages, clean the tree if needed, and rebuild. For _decimal, install libmpdec-dev only on Ubuntu releases where APT publishes it.
sudo apt install libssl-dev libsqlite3-dev libbz2-dev libzstd-dev
if apt-cache show libmpdec-dev >/dev/null 2>&1; then
sudo apt install libmpdec-dev
fi
make clean
./configure --with-ensurepip=install --prefix=/usr/local/python3.15
make -j"$(nproc)"
sudo make altinstall
Update or Remove Python 3.15 on Ubuntu
Update Python 3.15 PPA Packages
APT updates Deadsnakes packages like other packages from configured repositories. Refresh package lists and upgrade only installed Python 3.15 packages when you want a focused update:
sudo apt update
sudo apt install --only-upgrade python3.15 python3.15-venv python3.15-dev python3.15-nogil
The --only-upgrade option upgrades packages already installed on the system and avoids adding optional packages you did not previously choose.
Update Source-Built Python 3.15
Source builds do not update through APT. Create a reusable updater that finds the newest Python 3.15.0 prerelease or final source archive, checks the matching Python.org SHA-256 value, verifies the Sigstore bundle, rebuilds into /usr/local/python3.15, and keeps Ubuntu’s default python3 untouched.
cat <<'EOF' | sudo tee /usr/local/bin/update-python315 >/dev/null
#!/usr/bin/env bash
set -euo pipefail
INSTALL_PREFIX="/usr/local/python3.15"
PY315_BIN="$INSTALL_PREFIX/bin/python3.15"
BUILD_ROOT="${XDG_CACHE_HOME:-$HOME/.cache}/python3.15-source-update"
SOURCE_ROOT="$HOME/python3.15-source-build"
LOG_FILE="$SOURCE_ROOT/update.log"
SIGSTORE_IDENTITY="hugo@python.org"
SIGSTORE_ISSUER="https://github.com/login/oauth"
for cmd in curl gcc make python3 sha256sum tar; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: $cmd is required but not installed."
echo "Install the Python 3.15 source-build dependencies, then retry."
exit 1
fi
done
if [ ! -x "$PY315_BIN" ]; then
echo "Error: $PY315_BIN was not found."
echo "Install Python 3.15 from source before running this updater."
exit 1
fi
sudo true
mkdir -p "$BUILD_ROOT" "$SOURCE_ROOT"
LATEST_INFO="$(python3 - <<'PY'
import html as html_mod
import gzip
import re
from urllib.request import Request, urlopen
base_url = "https://www.python.org/ftp/python/3.15.0/"
headers = {"User-Agent": "LinuxCapable Python 3.15 updater"}
def fetch_text(url):
data = urlopen(Request(url, headers=headers), timeout=20).read()
if data.startswith(b"\x1f\x8b"):
data = gzip.decompress(data)
return data.decode("utf-8", "replace")
index_html = fetch_text(base_url)
versions = set(re.findall(r"Python-(3\.15\.0(?:a\d+|b\d+|rc\d+)?).tar\.xz", index_html))
def release_key(version):
match = re.fullmatch(r"3\.15\.0(?:(a|b|rc)(\d+))?", version)
if not match:
return (-1, -1)
order = {"a": 0, "b": 1, "rc": 2, None: 3}
return (order[match.group(1)], int(match.group(2) or 0))
if not versions:
raise SystemExit("could not find Python 3.15.0 source archives")
latest = sorted(versions, key=release_key)[-1]
archive = f"Python-{latest}.tar.xz"
release_slug = "python-" + latest.replace(".", "").lower()
release_url = f"https://www.python.org/downloads/release/{release_slug}/"
release_html = fetch_text(release_url)
checksum = ""
for row in re.findall(r"<tr>(.*?)</tr>", release_html, flags=re.S | re.I):
if archive not in row or "XZ compressed source tarball" not in row:
continue
plain = re.sub(r"<[^>]+>", "", html_mod.unescape(row))
compact = re.sub(r"\s+", "", plain)
match = re.search(r"([0-9a-fA-F]{64})", compact)
if match:
checksum = match.group(1).lower()
break
if not checksum:
raise SystemExit(f"could not find SHA-256 checksum for {archive}")
print(latest, archive, f"{base_url}{archive}", f"{base_url}{archive}.sigstore", checksum)
PY
)"
read -r LATEST_VERSION PY315_ARCHIVE PY315_URL PY315_SIGSTORE_URL PY315_SHA256 <<EOFINFO
$LATEST_INFO
EOFINFO
CURRENT_VERSION="$("$PY315_BIN" --version | awk '{print $2}')"
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "Already up to date."
exit 0
fi
printf 'Rebuild Python 3.15 from %s now? [y/N] ' "$PY315_ARCHIVE"
read -r ANSWER
case "$ANSWER" in
y|Y|yes|YES) ;;
*) echo "Update cancelled."; exit 0 ;;
esac
cd "$BUILD_ROOT"
rm -rf "Python-${LATEST_VERSION}" "$PY315_ARCHIVE" "${PY315_ARCHIVE}.sigstore" sigstore-venv
curl -fsSLO "$PY315_URL"
curl -fsSLO "$PY315_SIGSTORE_URL"
printf '%s %s\n' "$PY315_SHA256" "$PY315_ARCHIVE" | sha256sum -c -
python3 -m venv "$BUILD_ROOT/sigstore-venv"
"$BUILD_ROOT/sigstore-venv/bin/python" -m pip install --quiet --upgrade pip sigstore
"$BUILD_ROOT/sigstore-venv/bin/python" -m sigstore verify identity --bundle "${PY315_ARCHIVE}.sigstore" --cert-identity "$SIGSTORE_IDENTITY" --cert-oidc-issuer "$SIGSTORE_ISSUER" "$PY315_ARCHIVE"
tar -xf "$PY315_ARCHIVE"
cd "Python-${LATEST_VERSION}"
./configure --with-ensurepip=install --prefix="$INSTALL_PREFIX"
make -j"$(nproc)"
sudo make altinstall
NEW_VERSION="$("$PY315_BIN" --version | awk '{print $2}')"
"$PY315_BIN" -c "import ssl, sqlite3, bz2, compression.zstd; print('Source build core modules ready')"
if "$PY315_BIN" -c "import _decimal" >/dev/null 2>&1; then
echo "Source build _decimal accelerator ready"
else
echo "Source build completed without the _decimal accelerator"
fi
echo "$(date -Is): Updated to $NEW_VERSION" >> "$LOG_FILE"
echo "Successfully updated to $NEW_VERSION"
EOF
Make the updater executable:
sudo chmod +x /usr/local/bin/update-python315
Run this updater manually instead of scheduling it with cron. Source builds can fail because of dependency changes, failed verification, compiler errors, or prerelease regressions, and you should see that output before relying on the rebuilt interpreter.
Run the updater from any terminal directory:
update-python315
Current version: 3.15.0b1 Latest version: 3.15.0b1 Already up to date.
Recreate important virtual environments after a source rebuild if extension modules or wheels were compiled against the old prerelease.
Remove Python 3.15 PPA Packages
Remove only versioned Python 3.15 packages. Keep Ubuntu’s unversioned python3, python3-minimal, and other system Python packages installed.
sudo apt remove --purge python3.15 python3.15-venv python3.15-dev python3.15-nogil
sudo apt autoremove --purge --dry-run
Review the dry-run output, then remove leftover dependencies that are no longer needed:
sudo apt autoremove --purge
Verify that no versioned Python 3.15 packages remain installed:
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' 'python3.15*' 'libpython3.15*' 2>/dev/null | grep '^ii' || echo "No installed Python 3.15 packages found"
No installed Python 3.15 packages found
Remove the PPA only when no other Deadsnakes packages are needed. For a broader cleanup walkthrough, see how to remove a PPA from Ubuntu.
sudo add-apt-repository --remove -y ppa:deadsnakes/ppa
sudo apt update
Remove Source-Built Python 3.15
A source build installed with the documented prefix can be removed by deleting that prefix, the update helper, and the build workspace. Do not remove /usr/bin/python3 or Ubuntu’s Python packages.
cd "$HOME"
SOURCE_WORKSPACE="$HOME/python3.15-source-build"
UPDATE_CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/python3.15-source-update"
sudo rm -f /usr/local/bin/update-python315
sudo rm -rf /usr/local/python3.15
sudo rm -rf "$SOURCE_WORKSPACE"
rm -rf "$UPDATE_CACHE"
Confirm the source-built files were removed:
test ! -e /usr/local/python3.15 && test ! -e /usr/local/bin/update-python315 && test ! -e "$HOME/python3.15-source-build" && test ! -e "${XDG_CACHE_HOME:-$HOME/.cache}/python3.15-source-update" && echo "Source-built Python 3.15 removed"
Source-built Python 3.15 removed
Compare Python Versions on Ubuntu
Use Python 3.15 when you need the preview branch specifically. Stable projects usually belong on Ubuntu’s default Python or a supported stable branch such as Python 3.14 or Python 3.13 until Python 3.15 reaches its final release and your dependencies support it.
| Branch | Typical Ubuntu Use | Related Guide |
|---|---|---|
| Python 3.15 | Preview testing, compatibility work, and free-threaded experiments | Current page |
| Python 3.14 | Default runtime on Ubuntu 26.04 and current stable CPython branch | Install Python 3.14 on Ubuntu |
| Python 3.13 | Stable alternate branch for projects not ready for 3.14 | Install Python 3.13 on Ubuntu |
| Python 3.12 | Default runtime on Ubuntu 24.04 | Install Python 3.12 on Ubuntu |
| Python 3.11 | Older stable alternate branch for pinned applications | Install Python 3.11 on Ubuntu |
| Python 3.10 | Default runtime on Ubuntu 22.04 | Install Python 3.10 on Ubuntu |
Python 3.15 References for Ubuntu
- Python 3.15 documentation covers the preview branch’s standard library, language reference, and toolchain behavior.
- What’s New In Python 3.15 tracks feature and compatibility changes as the prerelease series evolves.
- Python Security Response Team explains upstream security handling for CPython releases.
- PyPI is the package index used by pip inside Python 3.15 virtual environments.
Conclusion
Python 3.15 can run on Ubuntu today as a separate prerelease interpreter through Deadsnakes packages or a verified Python.org source build. Keep Ubuntu’s default python3 untouched, build projects in venvs, and track the Python 3.15 schedule before using it outside testing or migration work. For project isolation, create a Python virtual environment on Ubuntu.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>