Install Python 3.13 on Ubuntu when you need the newest language features or want to evaluate the free-threaded preview described in Python Enhancement Proposal (PEP) 703. Common use cases include multi-threaded CPU testing, validating dependencies in continuous integration (CI) pipelines, and preparing long-lived services with upstream security support through October 2029.
Pick the path that matches your Ubuntu release: use Ubuntu repositories on 26.04 LTS, the Deadsnakes PPA (Personal Package Archive) on 24.04 and 22.04, or build from source when you need custom flags. You will finish with pip setup, virtual environments, and verification while keeping Ubuntu’s system Python intact.
When to Choose Python 3.13 on Ubuntu
Compare Python Releases for Ubuntu
Ubuntu LTS (Long Term Support) releases ship a default Python version that Canonical patches for the duration of that release. The comparison below shows when Python 3.13 is the right fit versus sticking with earlier releases, including upstream end-of-life dates and Ubuntu’s extended patching periods:
| 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
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.
Key Reasons to Choose Python 3.13
Python 3.13 stands out for:
- 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.
Pre-Flight Checklist
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
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 python3.13 package | 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, the APT-managed method for your release is recommended because it keeps Python 3.13 updates inside your normal package upgrades. APT is Ubuntu’s default package manager, so it stays aligned with system updates. Compile from source only when you need custom flags or the free-threaded preview.
These steps cover Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS. Follow the version-specific sections below because Ubuntu 26.04 installs Python 3.13 from the official repositories, while 22.04 and 24.04 use the Deadsnakes PPA or a source build.
Never replace /usr/bin/python3 or remove the system interpreter. Use versioned binaries like python3.13 and virtual environments to isolate projects safely.
Understand Support and Compatibility Limits
- 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.
Python 3.13 Pre-Installation Steps
Update System Before Proceeding
Refresh your package lists to ensure dependencies resolve cleanly before adding PPAs or compiling from source.
Open a terminal from Activities or your applications menu and run:
sudo apt update
Optionally upgrade existing packages to reduce conflicts during installation:
sudo apt upgrade
Install Python 3.13 on Ubuntu
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
Verify the installation:
python3.13 --version
Python 3.13.11
Your output should match the current 3.13.x patch version (for example, 3.13.11 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 packages
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 APT Pinning (Recommended)
The Deadsnakes PPA publishes multiple Python versions (3.7 through 3.13). Without APT pinning, future upgrades could unexpectedly install or upgrade other Python packages from the PPA. This optional step ensures only Python 3.13 packages come from Deadsnakes while other Python versions remain under Ubuntu’s 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*
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’s versions. The second rule overrides this for Python 3.13 specifically, giving it priority 700 so APT installs 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.11-1+noble1
Version table:
3.13.11-1+noble1 500
500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble/main amd64 Packages
On Ubuntu 22.04, the repository line shows jammy. 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
Critical Deadsnakes PPA Disclaimer: The maintainer states there is no guarantee of timely security updates. Production systems must track CVEs and be ready to recompile or sandbox workloads until patches arrive. Use the PPA 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 PPA installation
Verify the installation:
python3.13 --version
Python 3.13.11
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 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
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. The binary typically installs as python3.13t (with a ‘t’ suffix indicating the free-threaded variant), and it only exists when you compile with --disable-gil; PPA packages do not ship this binary.
python3.13t --version
Python 3.13.11
Check if the GIL is disabled using CPython’s internal API (available in Python 3.13+):
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.
Testing Free-Threaded 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
python3.13 cpu_bound_test.py
# Test on free-threaded Python 3.13 (if available)
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 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.11 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 update script
First, create a dedicated build directory. Using /opt keeps build artifacts separate from the final installation in /usr/local:
sudo install -d /opt/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 /opt/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 /opt/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="/opt/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 /opt/python3.13-build/update-python3.13.sh
Run the update script
Execute the script manually whenever you want to update to the latest 3.13.x patch release:
sudo /opt/python3.13-build/update-python3.13.sh
Checking for latest Python 3.13.x release... Found Python 3.13.11 Downloading Python-3.13.11.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: a1b2c3d4e5f6... Python-3.13.11.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.11
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.
Install Pip for Python 3.13
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.1.1 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. 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 installation
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 installation
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 data science wheel lag and PEP 668 rules
Note for data science workflows: NumPy, Pandas, and scikit-learn may lag behind new 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 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 Virtual Environment
When finished, run:
deactivate
This returns your shell to the system Python context.
Troubleshooting Common Python 3.13 Installation Issues
Missing 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"
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.
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 PPA
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.
If python3.13 -m venv reports that ensurepip is unavailable, install the venv package for PPA builds or confirm you set --with-ensurepip=install for source builds:
sudo apt install python3.13-venv
For source builds missing pip, rerun configure with ensurepip enabled or bootstrap pip via get-pip.py as 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)
Warning: 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
Clean Up Source-Compiled Installations
Remove source installs and related linker entries if you compiled Python 3.13 manually:
Warning: The next commands permanently delete the source-built Python 3.13 tree at
/usr/local/python3.13and the build directory at/opt/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 /opt/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.
Conclusion
Python 3.13 delivers the free-threaded preview and ongoing runtime improvements with upstream security support through October 2029. Ubuntu 26.04 provides it in the default repositories, while Ubuntu 24.04 and 22.04 can use the Deadsnakes PPA or a source build for custom flags. Your Ubuntu system now runs a current 3.13 interpreter alongside the default Python without touching /usr/bin/python3.
Next Steps After Installation
- Create a project virtual environment: Run
python3.13 -m venv ~/myproject, then activate it withsource ~/myproject/bin/activate. - Install your framework: Use
pip install django,pip install fastapi, or other tools, then test withpip checkfor compatibility warnings. - Set up a Python IDE: For a lightweight development environment, install IDLE on Ubuntu to get Python’s integrated development and learning environment.
- Monitor security advisories: Subscribe to the Python Security page and the CVE database search for PPA builds. Python 3.13 reaches upstream end-of-life in October 2029; plan migrations to Python 3.14 or newer before that date.
- Test in production: Use Python 3.13 on development workstations, CI runners, and testing environments first. Migrate production servers only after comprehensive testing confirms stability.
Useful Links
Reference these resources while working with Python 3.13 on Ubuntu:
- Python Official Website: Learn about Python features and downloads.
- Python Documentation: Access the official docs for configuration, libraries, and tutorials.
- PEP 719: Python 3.13 Release Schedule: Review the support timeline through October 2029.
- PEP 703: Making the Global Interpreter Lock Optional in CPython: Understand the free-threaded preview available in Python 3.13 builds.
- What’s New in Python 3.13: Explore new features, deprecations, and performance changes.