Python 3.13 introduces a free-threaded runtime preview that lets you test true multi-threaded parallelism without the Global Interpreter Lock, alongside interpreter performance updates and upstream security support through October 2029. To install Python 3.13 on Ubuntu, you add it alongside the system interpreter so APT and existing OS tools keep working without conflicts.
Ubuntu 26.04 LTS ships Python 3.13 in its official repositories, while Ubuntu 24.04 LTS and 22.04 LTS pick it up from the Deadsnakes PPA or a source compilation. The walkthrough covers every path, plus pip, virtual environments, troubleshooting, updates, and clean removal.
Install Python 3.13 on Ubuntu
Why Install Python 3.13 on Ubuntu
Python 3.13 brings several features worth evaluating:
- Free-threaded runtime preview: Optional
--disable-gilbuilds (PEP 703) let you evaluate multi-threaded scalability without the Global Interpreter Lock. - Language and standard library updates: Review What’s New in Python 3.13 for new features, deprecations, and behavior changes.
- Performance refinements: Interpreter and standard library updates can benefit some workloads, so validate performance with your own benchmarks.
- Security window through October 2029: Upstream support runs five years from release, giving modern features and a long runway for updates.
- Compatibility testing: Early 3.13 validation surfaces dependency gaps before production cutovers, so check the Python Package Index (PyPI) and project release notes for wheel support.
Python 3.13 Pre-Flight Checklist on Ubuntu
Before installing Python 3.13, verify your system state to avoid redundant installs or conflicts:
# Check if Python 3.13 is already installed
python3.13 --version 2>/dev/null && echo "Python 3.13 already present" || echo "Python 3.13 not found, safe to install"
# Confirm your Ubuntu version (target LTS releases only)
lsb_release -rs
# Check available disk space (source builds can require several hundred MB)
df -h /usr/local
Python 3.13 not found, safe to install 26.04 Filesystem Size Used Avail Use% Mounted on /dev/sda3 98G 22G 71G 24% /usr/local
Your version output should be 22.04, 24.04, or 26.04. Disk usage values will vary based on your system.
If Python 3.13 is already installed, you can skip to the “Work in Python 3.13 Virtual Environments” section unless you need to rebuild with custom flags (like --disable-gil).
Choose Your Python 3.13 Installation Method on Ubuntu
Ubuntu 26.04 LTS ships Python 3.13, while Ubuntu 24.04 LTS and 22.04 LTS require the Deadsnakes PPA or a source build. Choose the installation method that best fits your workflow:
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Ubuntu repositories (26.04 LTS) | Ubuntu package search for python3.13 | Ubuntu default | Automatic via apt upgrade | 26.04 LTS users who want Canonical-managed updates |
| Deadsnakes PPA (24.04/22.04 LTS) | Deadsnakes PPA | Latest 3.13.x | APT updates from the PPA (monitor advisories) | 22.04/24.04 users who want 3.13 without compiling |
| Compile from source | Python Source | Latest 3.13.x | Manual rebuilds | Custom flags, free-threaded testing, air-gapped hosts |
For most users, pick the APT method that matches your release because it keeps Python 3.13 updates inside your normal apt upgrade cycle. Compile from source only when you need custom flags or the free-threaded preview.
Ubuntu 26.04 LTS installs Python 3.13 from the official repositories, while 22.04 and 24.04 LTS use the Deadsnakes PPA or a source build. Follow the section that matches your release.
Keep /usr/bin/python3 pointed at the system interpreter. Use versioned binaries like python3.13 and virtual environments to isolate projects safely.
Python 3.13 Support and Compatibility Limits on Ubuntu
- Ubuntu repository availability varies: Ubuntu 26.04 LTS ships Python 3.13, while Ubuntu 24.04 LTS and 22.04 LTS require the Deadsnakes PPA or a source build.
- Deadsnakes PPA is community maintained: Monitor security advisories and be ready to rebuild from source if patched packages lag.
- Dependency readiness varies: Check PyPI package pages or project release notes for 3.13 wheels, and run
pip checkafter installing dependencies to verify compatibility. - Free-threaded builds are experimental: The
--disable-giloption is for evaluation and performance research, not production use. Library compatibility varies significantly.
Python 3.13 reaches upstream end-of-life in October 2029, per the official release schedule (PEP 719). Plan migrations to Python 3.14 or newer before that date if you need ongoing security updates beyond the five-year support window.
Prepare Ubuntu Before Installing Python 3.13
Update Ubuntu Before Installing Python 3.13
Refresh your package lists to ensure dependencies resolve cleanly before adding PPAs or compiling from source.
If your user account does not have sudo access yet, add a sudo user on Ubuntu first, then continue with the installation steps.
Optionally upgrade existing packages to reduce conflicts during installation:
sudo apt upgrade
Install Python 3.13 on Ubuntu with APT (26.04/24.04/22.04)
Use the Ubuntu repositories on 26.04 LTS, the Deadsnakes PPA on 24.04 LTS and 22.04 LTS, or compile from source when you need custom build flags or air-gapped installation.
Install Python 3.13 from Ubuntu repositories (26.04 LTS)
Ubuntu 26.04 LTS ships Python 3.13 by default, but the venv and dev modules are separate packages. Install or confirm the interpreter and common add-ons:
sudo apt install python3.13 python3.13-venv python3.13-dev
python3.13 --version
Python 3.13.12
Your output should match the current 3.13.x patch version (for example, 3.13.12 on Ubuntu 26.04 LTS).
Install Python 3.13 via Deadsnakes PPA (24.04/22.04 LTS)
Use the Deadsnakes PPA on Launchpad for Ubuntu 24.04 LTS and 22.04 LTS. It does not publish builds for Ubuntu 26.04 LTS, so use the Ubuntu repositories there. The commands below are the same for 24.04 and 22.04:
Add the Deadsnakes PPA and Install Python 3.13
Install the repository helper and GPG tooling if your minimal system lacks them:
sudo apt install software-properties-common gpg -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
Configure Python 3.13 APT Pinning (Optional)
Most users can skip APT pinning here because Deadsnakes Python packages are versioned and do not replace Ubuntu’s default python3 package. Use this optional step only if you manage multiple Deadsnakes Python versions on the same host or want stricter APT source control:
cat <<EOF | sudo tee /etc/apt/preferences.d/python313-deadsnakes-pin
Package: *
Pin: release o=LP-PPA-deadsnakes
Pin-Priority: 100
Package: python3.13* libpython3.13*
Pin: release o=LP-PPA-deadsnakes
Pin-Priority: 700
EOF
The first rule deprioritizes all Deadsnakes packages below the default priority of 500, so APT prefers Ubuntu packages when both sources provide a package. The second rule overrides this for the Python 3.13 package family, giving it priority 700 so APT selects Python 3.13 from the PPA. After creating the pin file, update APT to apply the new priorities:
sudo apt update
Confirm the PPA is providing Python 3.13 packages before installing:
apt-cache policy python3.13
python3.13:
Installed: (none)
Candidate: 3.13.12-1+noble1
Version table:
3.13.12-1+noble1 700
100 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble/main amd64 Packages
On Ubuntu 22.04, the repository line shows jammy. With pinning enabled, APT may show the repository source line at 100 while the package version line shows 700, which means the package-specific pin is active. If you skip pinning, the version priority is usually 500. If the candidate version is (none), the PPA does not have packages yet, so use the source build method until builds are published.
Install Python 3.13 from the PPA:
sudo apt install python3.13 python3.13-venv python3.13-dev
The Deadsnakes maintainer does not guarantee timely security updates. For production workloads, track CVEs and be ready to recompile or isolate workloads until patched packages are published. Use the PPA primarily for development, CI, or testing, and rely on your release’s default Python (3.12 on 24.04, 3.10 on 22.04) for system tooling.
Monitor the Python Security page and the CVE database search for Python vulnerabilities. Subscribe to the Python Security Announcements mailing list to receive notifications when security patches are released.
Verify the Python 3.13 PPA Installation
python3.13 --version
Python 3.13.12
Run a quick module test to confirm critical standard library modules compiled correctly:
python3.13 -c "import ssl, sqlite3, bz2; print('Python 3.13 ready on Ubuntu')"
Python 3.13 ready on Ubuntu
Install Additional Python 3.13 Packages (Optional)
Add optional components when you need debugging symbols, dbm bindings, or Tkinter GUI support:
python3.13-full for the full standard library bundle:
sudo apt install python3.13-full
python3.13-dbg for debugging and profiling:
sudo apt install python3.13-dbg
python3.13-gdbm for GNU dbm bindings:
sudo apt install python3.13-gdbm
python3.13-tk for Tkinter GUI applications:
sudo apt install python3.13-tk
The
python3.13-fullmeta-package is available in Ubuntu 26.04 and the Deadsnakes PPA. Thepython3-fullmeta-package installs extras for your system interpreter (Python 3.13 on 26.04, Python 3.12 on 24.04, Python 3.10 on 22.04).
Combine packages in a single command if you need multiple extras:
sudo apt install python3.13-dbg python3.13-gdbm python3.13-tk
Compile Python 3.13 from Source on Ubuntu
Compile Python 3.13 when you need full control over optimization flags, installation prefixes, or the free-threaded build. Source installs live alongside Ubuntu’s system interpreter without overwriting /usr/bin/python3.
Download Python 3.13 Source Tarball
Download the latest 3.13.x release from python.org, then verify the GPG signature and SHA-256 checksum before extracting. The snippet below uses curl to discover the newest patch version automatically:
Install baseline download utilities if they are missing on minimal images:
sudo apt install curl wget ca-certificates gpg
PY313_VERSION="$(curl -s https://www.python.org/ftp/python/ | grep -oE '3\.13\.[0-9]+' | sort -V | tail -1)" || { echo "Failed to fetch Python version"; exit 1; }
[ -z "$PY313_VERSION" ] && { echo "No 3.13.x version found"; exit 1; }
wget "https://www.python.org/ftp/python/${PY313_VERSION}/Python-${PY313_VERSION}.tar.xz"
wget "https://www.python.org/ftp/python/${PY313_VERSION}/Python-${PY313_VERSION}.tar.xz.asc"
curl -fsSL https://keys.openpgp.org/vks/v1/by-fingerprint/7169605F62C751356D054A26A821E680E5FA6305 | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/python-release.gpg
gpg --no-default-keyring --keyring /usr/share/keyrings/python-release.gpg --verify "Python-${PY313_VERSION}.tar.xz.asc" "Python-${PY313_VERSION}.tar.xz"
sha256sum "Python-${PY313_VERSION}.tar.xz"
tar -xf "Python-${PY313_VERSION}.tar.xz"
cd "Python-${PY313_VERSION}"
Compare the SHA-256 output with the hash listed on the Python.org downloads page. The GPG signature is signed by Pablo Galindo Salgado, the Python 3.13 release manager (fingerprint 7169 605F 62C7 5135 6D05 4A26 A821 E680 E5FA 6305). A successful verification shows “Good signature” in the output:
gpg: Signature made Fri 05 Dec 2025 01:15:20 PM UTC gpg: using RSA key 7169605F62C751356D054A26A821E680E5FA6305 gpg: Good signature from "Pablo Galindo Salgado <Pablogsal@gmail.com>"
If you cannot reach python.org, check the Python.org downloads page for the latest 3.13.x release and substitute that version manually.
Install Python 3.13 Build Dependencies
Install the libraries needed for SSL, compression, readline, XML/expat, Tk, and UUID support:
sudo apt install -y build-essential make pkg-config \
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev \
libgdbm-dev libgdbm-compat-dev libnss3-dev libexpat1-dev libdb-dev \
libncurses-dev tk-dev libbluetooth-dev
The same dependency set works on Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS. Missing packages lead to disabled stdlib modules: expat for XML parsing, ncurses for interactive shells, tkinter for GUI support, and dbm/ssl/bz2 for common libraries.
Configure and Build Python 3.13
Compile with optimization and link-time optimization while installing under /usr/local/python3.13 to keep the system interpreter untouched:
./configure --enable-optimizations --with-lto --with-ensurepip=install --prefix=/usr/local/python3.13
make -j"$(nproc)"
sudo make altinstall
--enable-optimizations runs profile-guided optimization (PGO), which compiles Python, executes the test suite, then recompiles using the collected profile data for faster runtime performance. --with-lto enables link-time optimization for additional cross-module inlining. --with-ensurepip=install bundles pip into the build so it is available immediately after installation. --prefix=/usr/local/python3.13 places the entire installation under a dedicated directory instead of writing to system paths.
To test the free-threaded preview, append
--disable-gilto the configure command. This build is experimental and intended for benchmarking CPU-bound parallel workloads, not production use. Many third-party libraries expect the GIL and may crash or behave incorrectly without it.
make altinstall prevents overwriting /usr/bin/python3 while adding /usr/local/python3.13/bin/python3.13.
Test Free-Threaded Python 3.13 Build (Optional)
If you compiled with --disable-gil, verify the free-threaded build is working correctly. With the custom prefix used in this guide, the binary typically installs as /usr/local/python3.13/bin/python3.13t (with a t suffix indicating the free-threaded variant). It only exists when you compile with --disable-gil; PPA packages do not ship this binary.
/usr/local/python3.13/bin/python3.13t --version
Python 3.13.12
Check if the GIL is disabled using CPython’s internal API (available in Python 3.13+):
/usr/local/python3.13/bin/python3.13t -c "import sys; print('GIL disabled:', not sys._is_gil_enabled())"
GIL disabled: True
sys._is_gil_enabled() is a CPython internal API (underscore-prefixed) introduced in Python 3.13 for testing purposes. It is not part of the stable Python API and may change in future releases. Use this command only for verification during development.
Free-threaded builds benefit CPU-bound code that runs true parallel threads. Workloads like numerical computing, image processing, and data transformation can scale across cores without GIL contention.
I/O-bound code (web servers, database queries, file operations) sees little improvement because threads already release the GIL during I/O waits in standard Python. Test your specific workload before committing to no-GIL builds in development environments.
Test Free-Threaded Python 3.13 Performance
To measure if no-GIL actually helps your workload, create a simple multi-threaded benchmark and run it on both standard and free-threaded Python 3.13:
cat > cpu_bound_test.py << 'EOF'
import threading
import time
def cpu_bound_task(n):
total = 0
for i in range(n):
total += i * i
return total
# Run CPU-bound work in 4 threads
start = time.time()
threads = []
for _ in range(4):
t = threading.Thread(target=cpu_bound_task, args=(10000000,))
threads.append(t)
t.start()
for t in threads:
t.join()
elapsed = time.time() - start
print(f"Time: {elapsed:.2f}s")
EOF
# Test on standard Python 3.13 source build (custom prefix)
/usr/local/python3.13/bin/python3.13 cpu_bound_test.py
# Test on free-threaded Python 3.13 source build (if available)
/usr/local/python3.13/bin/python3.13t cpu_bound_test.py 2>/dev/null || echo "Free-threaded not installed"
This script is a lightweight quick check, not a formal benchmark. Results vary by hardware, compiler flags, and workload size, so compare runs only on the same host.
If python3.13t is significantly faster (especially with 4+ threads), your workload benefits from no-GIL. If times are similar, the GIL is not your bottleneck, and you should optimize your algorithm instead.
Free-threaded Python support varies significantly across third-party libraries. Many packages are not tested with no-GIL builds and may crash or produce incorrect results. Check individual project documentation and issue trackers for free-threaded compatibility status before depending on specific libraries. Use the standard GIL-enabled Python 3.13 for production workloads until the ecosystem matures.
Register Python 3.13 Libraries and Test the Build
If you installed Python 3.13 to a custom prefix like /usr/local/python3.13, register its shared libraries with the system linker so Python can load them at runtime. If you installed to the system Python prefix or via PPA, skip this step.
# Only needed for custom prefix installations
echo '/usr/local/python3.13/lib' | sudo tee /etc/ld.so.conf.d/python3.13.conf
sudo ldconfig
sudo ln -sf /usr/local/python3.13/bin/python3.13 /usr/local/bin/python3.13
ldconfig reads all paths in /etc/ld.so.conf.d/, updates the dynamic linker cache, and enables the OS to find shared libraries (like libpython3.13.so) when you run Python. The symlink in /usr/local/bin adds convenience so python3.13 works from any directory without typing the full path.
Verify the build and confirm critical modules compiled successfully:
python3.13 --version
python3.13 -c "import ssl, sqlite3, bz2; print('Source build is healthy')"
Python 3.13.12 Source build is healthy
If the second command fails, reinstall missing -dev packages using the “Install Build Dependencies” section above, rerun ./configure, and rebuild with make -j"$(nproc)" and sudo make altinstall.
Update a Source-Built Python 3.13 Installation
Source-built Python does not receive automatic updates from APT. When a new 3.13.x patch release is available, you need to download the new source, recompile, and reinstall. The script below automates this process while keeping your existing installation prefix at /usr/local/python3.13.
Create the Python 3.13 Update Script
First, create a dedicated build directory under /usr/local/src to keep source trees and build artifacts organized alongside your installation prefix:
sudo install -d /usr/local/src/python3.13-build
Next, create the update script. This script performs several safety checks before rebuilding:
- Root check: Verifies you are running as root since compilation installs to system directories.
- Tool check: Confirms required build tools (curl, tar, gcc, make, gpg) are available.
- Keyring check: Verifies the Python release GPG keyring exists for signature verification.
- Existing install check: Confirms a prior source build exists before attempting an upgrade.
- Version detection: Fetches the latest 3.13.x version number from python.org.
cat <<'EOF' | sudo tee /usr/local/src/python3.13-build/update-python3.13.sh
#!/usr/bin/env bash
set -euo pipefail
# Verify running as root
if [ "$(id -u)" -ne 0 ]; then
echo "Run as root: sudo /usr/local/src/python3.13-build/update-python3.13.sh"
exit 1
fi
# Check required build tools
for cmd in curl tar gcc make gpg; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: $cmd is required. Install build-essential, curl, tar, and gpg."
exit 1
fi
done
# Verify GPG keyring exists
KEYRING="/usr/share/keyrings/python-release.gpg"
if [ ! -f "$KEYRING" ]; then
echo "Error: $KEYRING not found. Import Python release keys first."
exit 1
fi
# Verify existing source installation
PREFIX="/usr/local/python3.13"
if [ ! -x "$PREFIX/bin/python3.13" ]; then
echo "Error: $PREFIX/bin/python3.13 not found. Install Python 3.13 from source first."
exit 1
fi
# Detect latest 3.13.x version
echo "Checking for latest Python 3.13.x release..."
LATEST="$(curl -s https://www.python.org/ftp/python/ | grep -oE '3\.13\.[0-9]+' | sort -V | tail -1)"
if [ -z "$LATEST" ]; then
echo "Error: Could not determine the latest 3.13.x version."
exit 1
fi
echo "Found Python $LATEST"
# Download and verify source
WORKDIR="/usr/local/src/python3.13-build"
cd "$WORKDIR"
rm -rf "Python-${LATEST}"
rm -f "Python-${LATEST}.tar.xz" "Python-${LATEST}.tar.xz.asc"
echo "Downloading Python-${LATEST}.tar.xz..."
curl -fsSLO "https://www.python.org/ftp/python/${LATEST}/Python-${LATEST}.tar.xz"
curl -fsSLO "https://www.python.org/ftp/python/${LATEST}/Python-${LATEST}.tar.xz.asc"
echo "Verifying GPG signature..."
gpg --no-default-keyring --keyring "$KEYRING" --verify "Python-${LATEST}.tar.xz.asc" "Python-${LATEST}.tar.xz"
echo "SHA-256 checksum:"
sha256sum "Python-${LATEST}.tar.xz"
# Extract and compile
echo "Extracting source..."
tar -xf "Python-${LATEST}.tar.xz"
cd "Python-${LATEST}"
echo "Configuring build (this takes a few minutes)..."
./configure --enable-optimizations --with-lto --with-ensurepip=install --prefix="$PREFIX"
echo "Compiling (this may take 10-30 minutes depending on CPU)..."
make -j"$(nproc)"
echo "Installing..."
make altinstall
# Verify
echo ""
echo "Update complete:"
"$PREFIX/bin/python3.13" --version
EOF
sudo chmod +x /usr/local/src/python3.13-build/update-python3.13.sh
Run the Python 3.13 Update Script
Execute the script manually whenever you want to update to the latest 3.13.x patch release:
sudo /usr/local/src/python3.13-build/update-python3.13.sh
Checking for latest Python 3.13.x release... Found Python 3.13.12 Downloading Python-3.13.12.tar.xz... Verifying GPG signature... gpg: Signature made Fri 05 Dec 2025 01:15:20 PM UTC gpg: using RSA key 7169605F62C751356D054A26A821E680E5FA6305 gpg: Good signature from "Pablo Galindo Salgado <Pablogsal@gmail.com>" SHA-256 checksum: 3f7c2b8a9d1e... Python-3.13.12.tar.xz Extracting source... Configuring build (this takes a few minutes)... [configure output truncated] Compiling (this may take 10-30 minutes depending on CPU)... [compilation output truncated] Installing... Update complete: Python 3.13.12
Avoid automating this with cron. Compilation can fail due to missing dependencies, test failures, or network issues. Run the script manually and review the output to catch any errors before they affect your projects.
Compare Python Versions on Ubuntu (Reference)
Ubuntu LTS releases ship different default Python versions, and Canonical patches those defaults for the life of the release. Use this comparison table when deciding whether Python 3.13 is the right target for your project or whether another version is a better fit.
| Python Version | Availability on Ubuntu | Choose It When | Trade-offs |
|---|---|---|---|
| Install Python 3.8 on Ubuntu | Deadsnakes PPA or source build only | Legacy applications pinned to 3.8-only dependencies or short-term migration windows | Upstream end-of-life October 2024; security patches ended; ecosystem support declining |
| Install Python 3.10 on Ubuntu | Ubuntu 22.04 LTS default | Production environments prioritizing stability on 22.04 LTS (supported through June 2027) | Upstream Python 3.10 EOL October 2026; Ubuntu continues patching until 22.04 LTS ends |
| Install Python 3.11 on Ubuntu | Deadsnakes PPA for 22.04/24.04; source builds | Projects needing 3.11 features without jumping to 3.12 or 3.13 | Upstream EOL October 2027; not a system default on any current Ubuntu LTS |
| Install Python 3.12 on Ubuntu | Ubuntu 24.04 LTS default | General-purpose development on 24.04 LTS (supported through June 2029) | Upstream Python 3.12 EOL October 2028; Ubuntu continues patching until 24.04 LTS ends |
| Python 3.13 | Ubuntu 26.04 LTS default; Deadsnakes PPA for 24.04/22.04; source builds for custom needs | Teams testing free-threaded CPython preview, projects adopting new 3.13 features, forward-looking development targeting upstream support through October 2029 | Not in Ubuntu 22.04/24.04 repositories; community packages lack guaranteed security SLAs; some third-party wheels may lag |
| Install Python 3.14 on Ubuntu | Source builds available immediately; PPA when published for supported releases | Early adopters validating continued free-threaded work, benchmarking new interpreter changes, planning for support through October 2030 | Not in Ubuntu repositories; PPA patches can trail upstream; some wheels lag new releases |
Recommendation for Choosing Python 3.13 on Ubuntu
Stick with the Ubuntu default Python for your release when you prefer Canonical-managed security updates. Use Python 3.13 on development workstations, CI runners, or isolated services that need the free-threaded preview or newer 3.13 features, and plan to move to Python 3.14 when you want the longer security runway. Avoid replacing the system Python that ships with Ubuntu.
Install Pip for Python 3.13 on Ubuntu
Ubuntu and Deadsnakes packages do not install pip by default, so verify it before installing third-party packages.
Install Pip with python3.13-venv
Use a Python 3.13 virtual environment so pip installs cleanly on Ubuntu repository builds and stays isolated from system packages. If you compiled from source with --with-ensurepip=install, you can skip the apt step.
sudo apt install python3.13-venv -y
python3.13 -m venv ~/venvs/py313-base
source ~/venvs/py313-base/bin/activate
pip --version
pip 25.3 from /home/ubuntu/venvs/py313-base/lib/python3.13/site-packages/pip (python 3.13)
The pip version and path vary by release and venv location. This example uses Ubuntu 26.04 with a venv created under
~/venvs/py313-base.
Ubuntu repository builds disable ensurepip for the system interpreter. On Ubuntu 26.04 LTS, python3.13 -m venv fails with an ensurepip is not available error until python3.13-venv is installed. Deadsnakes PPA builds include ensurepip if you need a global pip install (venvs are still recommended). Running ensurepip on the PPA installs pip under /usr/local, so the path looks like:
python3.13 -m ensurepip --upgrade
python3.13 -m pip --version
pip 25.3 from /usr/local/lib/python3.13/dist-packages/pip (python 3.13)
On source builds with a custom prefix, the pip path reflects that prefix. Use python3.13 -m pip --version to confirm the install location.
Do not use
ensurepipon Ubuntu 26.04 repository Python, because it is disabled for the system interpreter.
Bootstrap Pip with get-pip.py
For air-gapped hosts or custom builds, download the bootstrap script and review it before running with Python 3.13. Prefer virtual environments (or ensurepip on PPA/source builds) and only fall back to get-pip.py when other methods are blocked.
curl -fsSLo get-pip.py https://bootstrap.pypa.io/get-pip.py
python3.13 get-pip.py
rm get-pip.py
This installs pip, setuptools, and wheel together. Always fetch a fresh copy of get-pip.py before rerunning the installer.
Manage Packages with python3.13 -m pip
Run these commands inside your active Python 3.13 virtual environment or after installing pip with ensurepip on PPA/source builds:
python3.13 -m pip install package_name
python3.13 -m pip install --upgrade package_name
python3.13 -m pip uninstall package_name
Replace package_name with libraries like numpy, fastapi, or django. For detailed pip workflows, see Install Python pip on Ubuntu.
After installing dependencies, verify compatibility and check for conflicts:
python3.13 -m pip check
No broken requirements found.
This command reports broken dependencies, version conflicts, and missing packages that your installed libraries require. If issues are detected, pip lists them so you can fix conflicts before committing code that depends on those packages.
Install Python Packages and Verify Compatibility
After pip is working, install packages relevant to your workflow and test compatibility with pip check. Python 3.13 is new, so dependency support varies across projects. Always test critical dependencies before deploying.
Test FastAPI with Python 3.13
Example: Install FastAPI and verify compatibility
python3.13 -m pip install fastapi uvicorn
python3.13 -m pip check
If pip check returns no conflicts, FastAPI is ready for Python 3.13. If warnings appear, review the output and consider using a venv to isolate the installation.
Test Django with Python 3.13
Example: Install Django and run compatibility tests
python3.13 -m pip install django psycopg2-binary
python3.13 -m pip check
If psycopg2-binary installation fails with a compiler error, the package requires build tools. Install the necessary headers: sudo apt install python3.13-dev, then retry.
Handle Python 3.13 Data Science Wheel Lag and PEP 668
Data science wheel availability: NumPy, Pandas, and scikit-learn may lag behind new Python releases. If installation fails, check the package’s GitHub releases or PyPI package page for 3.13 wheel support. Avoid --break-system-packages; use virtual environments for all work.
Ubuntu 24.04 LTS and 26.04 LTS mark the system Python as externally managed under PEP 668, so pip refuses to write to
/usrwithout a virtual environment. Deadsnakes PPA builds and source builds are not externally managed, but you should still use venvs to isolate projects.Install packages inside a virtual environment instead of bypassing protections. If you compiled Python 3.13 from source, pip installs to its prefix without PEP 668 prompts, but venvs still prevent cross-project conflicts.
Use virtual environments for all project work. Avoid
--break-system-packages; it is only suitable for disposable test systems, not daily development or production machines.
Work in Python 3.13 Virtual Environments
Virtual environments isolate dependencies per project. Each environment gets its own interpreter copy and package directory, preventing version conflicts between projects. For expanded guidance, visit Create Python Virtual Environments on Ubuntu.
Create a Python 3.13 Virtual Environment
Choose a directory for your environments (for example ~/venvs) and create one with Python 3.13:
python3.13 -m venv ~/venvs/py313
Swap ~/venvs/py313 for any path that matches your workflow.
Activate the Python 3.13 Virtual Environment
Activate the environment so python and pip resolve to the local interpreter:
source ~/venvs/py313/bin/activate
The shell prompt updates with the environment name, indicating activation.
Deactivate the Python 3.13 Virtual Environment
When finished, run:
deactivate
This returns your shell to the system Python context.
Troubleshooting Common Python 3.13 Installation Issues
Missing Python 3.13 Development Headers During Compilation
If ./configure completes but reports disabled modules for SSL, bz2, sqlite, readline, or other standard library features, critical development headers are missing. Identify which modules were disabled and install the corresponding packages.
Review the configure output to identify disabled modules:
./configure --enable-optimizations --with-ensurepip=install --prefix=/usr/local/python3.13 2>&1 | grep "disabled\|WARNING"
You may also see a warning about bundled libmpdec during ./configure on Ubuntu. This warning does not prevent a successful Python 3.13 build as long as required modules are not listed as disabled.
Common missing packages and the modules they enable:
- SSL module disabled -> Install
sudo apt install libssl-dev - sqlite3 module disabled -> Install
sudo apt install libsqlite3-dev - bz2 module disabled -> Install
sudo apt install libbz2-dev - readline module disabled -> Install
sudo apt install libreadline-dev - dbm module disabled -> Install
sudo apt install libgdbm-dev
After installing the missing packages, rerun ./configure and make -j"$(nproc)" to rebuild with full module support.
Python 3.13 Shared Library Linking Errors
If running python3.13 returns error while loading shared libraries: libpython3.13.so.1.0: cannot open shared object file, the linker cannot find the Python library. This occurs when you installed to a custom prefix and forgot to register it with ldconfig.
Locate the library:
find /usr/local -name "libpython3.13.so*"
If the library exists, register its directory and refresh the cache:
echo "/usr/local/python3.13/lib" | sudo tee /etc/ld.so.conf.d/python3.13.conf
sudo ldconfig
Verify the library loads:
python3.13 --version
If the library does not exist, the compilation likely failed. Rerun ./configure, make -j"$(nproc)", and sudo make altinstall in the source directory, then try the ldconfig steps again.
Resolve Externally Managed Environment Errors
On Ubuntu 24.04 LTS and 26.04 LTS, the system Python is externally managed under PEP 668, so pip blocks direct installs to /usr without a virtual environment. The error looks like this:
error: externally-managed-environment This environment is externally managed. To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.13/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.
Your output may wrap lines differently, but the fix is the same: use a virtual environment.
Create a venv instead of bypassing protections:
python3 -m venv myproject_env
source myproject_env/bin/activate
pip install package-name
Swap python3 with python3.13 if you want the Python 3.13 interpreter inside the venv. Skip --break-system-packages on any host you care about. Virtual environments isolate dependencies cleanly without risking apt-managed files.
APT Errors After Adding the Deadsnakes PPA on Ubuntu 26.04
If apt update reports a missing Release file, you are on an unsupported codename (Ubuntu 26.04 LTS does not have Deadsnakes builds):
E: The repository 'https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute Release' does not have a Release file.
Use the Ubuntu repositories on 26.04 LTS or compile from source instead of the PPA.
If apt errors mention Python after adding the Deadsnakes PPA, ensure you did not modify the system /usr/bin/python3 symlink. It should point to Ubuntu’s default interpreter.
Check the symlink:
ls -la /usr/bin/python3
Example outputs by release:
lrwxrwxrwx 1 root root 10 Nov 10 12:00 /usr/bin/python3 -> python3.13 lrwxrwxrwx 1 root root 10 Nov 10 12:00 /usr/bin/python3 -> python3.12 lrwxrwxrwx 1 root root 10 Nov 10 12:00 /usr/bin/python3 -> python3.10
Restore it if needed:
# Ubuntu 26.04 LTS
sudo ln -sf /usr/bin/python3.13 /usr/bin/python3
# Ubuntu 24.04 LTS
sudo ln -sf /usr/bin/python3.12 /usr/bin/python3
# Ubuntu 22.04 LTS
sudo ln -sf /usr/bin/python3.10 /usr/bin/python3
Always call Python 3.13 explicitly with python3.13 instead of altering system links.
GPG Key Import Failures for Source Builds
If verifying the Python source tarball fails with “No public key” or “Can’t check signature” errors, the release signing key may not have imported correctly. First, confirm the keyring file exists:
ls -la /usr/share/keyrings/python-release.gpg
If missing, re-import the key:
curl -fsSL https://keys.openpgp.org/vks/v1/by-fingerprint/7169605F62C751356D054A26A821E680E5FA6305 | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/python-release.gpg
If the key server is unreachable (network restrictions or temporary outage), you can skip GPG verification and rely solely on SHA-256 checksum verification. Compare the checksum output from sha256sum Python-*.tar.xz with the hash on the Python.org downloads page. GPG verification adds an extra layer of assurance but is not strictly required if the checksum matches.
C Extension Build Failures During pip install
Some Python packages like psycopg2, cryptography, and numpy require compilation (C extensions). If pip install package-name fails with compiler errors, you need Python development headers. Install them:
sudo apt install python3.13-dev
For Deadsnakes PPA: The package is called python3.13-dev. For source builds: Development headers were built during compilation and live in /usr/local/python3.13/include/python3.13.
After installing headers, retry the package installation:
python3.13 -m pip install psycopg2-binary # or the package that failed
If compilation still fails, the package may not have released Python 3.13 wheels yet. Check the package’s PyPI package page or GitHub releases to confirm support before reporting a bug.
Fix “ensurepip is not available” When Creating a Python 3.13 venv
If python3.13 -m venv fails with an ensurepip is not available message, the interpreter is installed but the venv support package is missing. This is common on Ubuntu 26.04 repository installs and can also happen on minimal 22.04/24.04 PPA installs when python3.13-venv was skipped.
The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3.13-venv package...
Install the venv package, recreate the environment, and verify pip inside the venv:
sudo apt install python3.13-venv
python3.13 -m venv ~/venvs/py313-test
~/venvs/py313-test/bin/pip --version
For source builds, rerun ./configure with --with-ensurepip=install (as shown in this guide), then rebuild and reinstall with sudo make altinstall. If you intentionally skipped ensurepip, use the get-pip.py fallback method shown earlier.
Downgrade or Switch Back to the System Python
If Python 3.13 introduces compatibility issues with critical packages or projects, you can safely revert to the system Python without affecting the interpreter Ubuntu ships. Virtual environments isolate project dependencies, so switching back affects only new projects.
Use the system interpreter directly for new environments. Ubuntu 26.04 LTS already uses Python 3.13 as the system interpreter, while Ubuntu 24.04 LTS uses Python 3.12 and Ubuntu 22.04 LTS uses Python 3.10.
Rebuild Existing Virtual Environments with the System Python
Virtual environments created with Python 3.13 are tied to that interpreter. To switch a project back to your system Python, remove the old venv and create a new one with your system interpreter (Python 3.12 on Ubuntu 24.04 LTS, Python 3.10 on Ubuntu 22.04 LTS). On Ubuntu 26.04 LTS, the system interpreter is already Python 3.13, so only recreate venvs if you want to reset dependencies.
# Remove the Python 3.13 venv
rm -rf ~/venvs/py313
# Create a new venv with the system Python
# Ubuntu 24.04 LTS
python3.12 -m venv ~/venvs/py312
# Ubuntu 22.04 LTS
python3.10 -m venv ~/venvs/py310
source ~/venvs/py312/bin/activate # or ~/venvs/py310
pip install -r requirements.txt # If using a requirements file
Virtual environments are isolated, so old ones with Python 3.13 remain on disk until you delete them. Once deleted, you cannot use them. Keep backups of requirements.txt or Pipfile to rebuild environments quickly.
Update Python 3.13 Packages
sudo apt update
sudo apt install --only-upgrade python3.13 python3.13-venv python3.13-dev python3.13-full
The --only-upgrade flag updates Python 3.13 packages only if they are already installed; it will not install Python 3.13 if it is missing. This prevents accidental installation while ensuring existing packages receive security patches from the Ubuntu repositories or the Deadsnakes PPA.
Remove Python 3.13 Packages (22.04/24.04 PPA)
On Ubuntu 26.04 LTS, Python 3.13 is the system interpreter and should not be removed. The commands below are intended for 22.04/24.04 PPA installations only. Verify your release before proceeding.
Uninstall Python 3.13 from the PPA if you no longer need it (this also removes the optional add-on packages if installed):
sudo apt remove --purge python3.13 python3.13-venv python3.13-dev python3.13-full python3.13-dbg python3.13-gdbm python3.13-tk
sudo apt autoremove
Confirm your Ubuntu version before removal:
lsb_release -rs
24.04
Remove the Deadsnakes PPA
Clean up the PPA and APT pinning configuration if you no longer require Python 3.13 packages:
sudo rm -f /etc/apt/preferences.d/python313-deadsnakes-pin
sudo add-apt-repository --remove ppa:deadsnakes/ppa -y
sudo apt update
If you only installed Python 3.13 from the Deadsnakes PPA (and did not also install a source build), verify the package and PPA are gone:
apt-cache policy python3.13
python3.13: Installed: (none) Candidate: (none) Version table:
If the output still shows a Deadsnakes candidate version, the PPA was not fully removed. Rerun the add-apt-repository --remove command and sudo apt update.
Clean Up Source-Compiled Python 3.13 Installations
Remove source installs and related linker entries if you compiled Python 3.13 manually:
The next commands permanently delete the source-built Python 3.13 tree at
/usr/local/python3.13and the build directory at/usr/local/src/python3.13-build. Back up any custom modules first withsudo cp -a /usr/local/python3.13 ~/python3.13-backup.
sudo rm -rf /usr/local/python3.13
sudo rm -rf /usr/local/src/python3.13-build
sudo rm /etc/ld.so.conf.d/python3.13.conf
sudo rm /usr/local/bin/python3.13 2>/dev/null
sudo rm /usr/local/bin/python3.13t 2>/dev/null
sudo ldconfig
Adjust the path if you used a custom prefix such as /opt/python3.13.
Verify the source-build files were removed:
test ! -d /usr/local/python3.13 && echo "Source prefix removed"
test ! -e /usr/local/bin/python3.13 && echo "Source symlink removed"
Source prefix removed Source symlink removed
Next Steps After Installing Python 3.13 on Ubuntu
Use these follow-up tasks to move from installation to day-to-day development without changing Ubuntu’s system Python.
- Create a project venv: Run
python3.13 -m venv ~/myproject, then activate it withsource ~/myproject/bin/activate. - Install project dependencies: Inside the active venv, use
python -m pip install django,python -m pip install fastapi, or your required packages, then runpython -m pip check. - Set up a lightweight IDE: If you want Python’s bundled editor for testing and learning, install IDLE on Ubuntu.
- Plan upgrades: Track Python 3.13 security updates and install Python 3.14 on Ubuntu when you need the longer support window, well before Python 3.13 reaches upstream end-of-life in October 2029.
- Validate production readiness: Benchmark your real workload, especially if you are evaluating the optional free-threaded build, before moving production services.
Useful Python 3.13 Resources for Ubuntu
Keep these references handy for release notes, security updates, and package availability checks.
- Python Official Website: Download releases and review project updates.
- Python Documentation: Read the language and standard library docs.
- What’s New in Python 3.13: Review new features, deprecations, and behavior changes.
- PEP 719: Python 3.13 Release Schedule: Confirm the support timeline through October 2029.
- PEP 703: Optional GIL in CPython: Understand free-threaded background and current limitations.
- Deadsnakes PPA on Launchpad: Check supported Ubuntu releases and package publishing status.
Python 3.13 on Ubuntu FAQ
Deadsnakes does not publish Python packages for Ubuntu 26.04 (resolute), so apt update returns a missing Release file error for that PPA. Use the Ubuntu 26.04 repositories for python3.13, or compile Python 3.13 from source if you need custom build flags.
python3.13 -m venv say ensurepip is not available?
The interpreter is installed, but the venv support package is missing. Install python3.13-venv, then recreate the virtual environment. For source builds, configure Python with --with-ensurepip=install before running make altinstall.
/usr/bin/python3 to point to Python 3.13?
No. Ubuntu tools depend on the distro-managed system Python. Keep /usr/bin/python3 pointed to Ubuntu’s default interpreter, run Python 3.13 with the versioned binary (python3.13), and use virtual environments for project isolation.
ensurepip on Ubuntu and Deadsnakes Python 3.13 installs?
Ubuntu repository builds disable ensurepip for the system interpreter, so use python3.13-venv and install packages inside a virtual environment. Deadsnakes PPA and source builds can use ensurepip, but virtual environments are still the recommended workflow. On Deadsnakes, ensurepip may install pip under /usr/local.
The Deadsnakes PPA publishes Python 3.13 packages for Ubuntu 24.04 LTS and 22.04 LTS. It does not support Ubuntu 26.04 LTS because that release already ships Python 3.13 from the official repositories. Add the PPA with sudo add-apt-repository ppa:deadsnakes/ppa, then install python3.13 via APT.
Ubuntu 24.04 and 22.04 default to Python 3.12 and 3.10 respectively, so updating means installing Python 3.13 alongside the existing system interpreter. Add the Deadsnakes PPA and install python3.13, or compile from source. The system Python stays unchanged at /usr/bin/python3, and you access 3.13 through the python3.13 binary.
Ubuntu 26.04 LTS ships Python 3.13 as the default system interpreter. Install it with sudo apt install python3.13 python3.13-venv python3.13-dev. Ubuntu 24.04 LTS defaults to Python 3.12 and Ubuntu 22.04 LTS defaults to Python 3.10.
Install python3.13-dev for the development headers, which includes Python.h. On Ubuntu 24.04 and 22.04, the package comes from the Deadsnakes PPA. On Ubuntu 26.04, it is in the default repositories. Source builds include headers automatically under the installation prefix.
Conclusion
Python 3.13 is running alongside Ubuntu’s default interpreter, with pip working inside a virtual environment and the versioned python3.13 binary available system-wide. Keep dependencies isolated in venvs, track upstream security advisories through October 2029, and install Python 3.14 on Ubuntu when you need the longer support window. For expanded pip workflows, see install pip on Ubuntu.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>