How to Install Python 3.13 on Ubuntu: 3 Proven Ways

To install Python 3.13 on Ubuntu you have three good options: the deadsnakes PPA (apt packages), uv (a standalone build in your home directory), or compiling from source with make altinstall. What you must not do is replace the system python3, and this guide shows exactly what breaks when you try. All commands were run on fresh Ubuntu 24.04.5 and 22.04.5 systems (containers), with Debian 13 for comparison, on 17 October 2026, when the current 3.13 release was 3.13.16.

# Option A: deadsnakes PPA
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.13 python3.13-venv
python3.13 -m venv ~/venvs/app && ~/venvs/app/bin/pip install requests

# Option B: uv (no root needed)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.13

# Never: point /usr/bin/python3 at 3.13

Which Python does Ubuntu ship?

$ grep PRETTY /etc/os-release; python3 --version; ls -l /usr/bin/python3
PRETTY_NAME="Ubuntu 24.04.5 LTS"
Python 3.12.3
lrwxrwxrwx. 1 root root 10 Nov 12  2025 /usr/bin/python3 -> python3.12

$ sudo apt-get install -y python3.13
E: Couldn't find any package by glob 'python3.13'
E: Couldn't find any package by regex 'python3.13'

Ubuntu 24.04 ships Python 3.12, Ubuntu 22.04 ships 3.10.12, and neither has a python3.13 package in its own archive. Debian 13 already uses 3.13 as the system Python:

Debian 13: PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
Python 3.13.5
lrwxrwxrwx. 1 root root 10 Jun 30  2025 /usr/bin/python3 -> python3.13

So on Ubuntu, any way to install Python 3.13 adds a second interpreter next to the system one. Ubuntu's own tools (apt helpers, add-apt-repository, cloud-init and others) keep using the system Python.

Option A: install Python 3.13 from the deadsnakes PPA

$ sudo apt-get install -y software-properties-common
$ sudo add-apt-repository -y ppa:deadsnakes/ppa
More info: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
Adding repository.

$ apt-cache policy python3.13 | head -3
python3.13:
  Installed: (none)
  Candidate: 3.13.16-1+noble1

$ sudo apt-get install -y python3.13 python3.13-venv python3.13-dev
$ python3.13 --version; which python3.13; python3 --version
Python 3.13.16
/usr/bin/python3.13
Python 3.12.3

The new interpreter is python3.13; plain python3 is still 3.12, which is correct. The same steps worked on Ubuntu 22.04 (Python 3.13.16 next to Python 3.10.12). The PPA also has a free-threaded (no-GIL) build and extras:

$ apt-cache search --names-only '^python3.13' | sort | head -12
python3.13 - Interactive high-level object-oriented language (version 3.13)
python3.13-dbg - Debug Build of the Python Interpreter (version 3.13)
python3.13-dev - Header files and a static library for Python (v3.13)
...
python3.13-nogil - No-GIL Build of the Python Interpreter (version 3.13)
python3.13-tk - Tkinter - Writing Tk applications with Python (version 3.13)
...

pip: use a virtual environment

Install Python 3.13 on Ubuntu 24.04: python3.13 has no pip, a venv does
Real output: python3.13 -m pip fails, the venv has pip.
$ python3.13 -m pip --version
/usr/bin/python3.13: No module named pip

$ python3.13 -m venv /opt/app313 && /opt/app313/bin/python --version && /opt/app313/bin/pip --version
Python 3.13.16
pip 26.2.1 from /opt/app313/lib/python3.13/site-packages/pip (python 3.13)
$ /opt/app313/bin/pip install -q requests && /opt/app313/bin/python -c 'import requests,sys; print(requests.__version__, sys.version.split()[0])'
2.34.2 3.13.16

The PPA interpreter has no pip of its own, and that is fine: install python3.13-venv, create a venv per project, and pip comes with it. This is the normal way to install Python packages on Ubuntu 24.04 anyway.

The mistake: making python3 point to 3.13

Many guides suggest update-alternatives so that python3 means 3.13. Here is what happened:

$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 2; python3 --version
update-alternatives: using /usr/bin/python3.13 to provide /usr/bin/python3 (python3) in auto mode
Python 3.13.16

$ sudo add-apt-repository -y ppa:git-core/ppa
  File "/usr/bin/add-apt-repository", line 3, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

apt_pkg and other system modules are built only for the system Python (3.12), so Ubuntu tools written in Python break. Undoing it was worse:

$ sudo update-alternatives --remove python3 /usr/bin/python3.13; ls -l /usr/bin/python3; python3 --version
ls: cannot access '/usr/bin/python3': No such file or directory
bash: line 1: python3: command not found

Removing the only alternative deleted /usr/bin/python3 completely, because the original python3 -> python3.12 link had been replaced by the alternatives link. On a real server that breaks apt hooks and many scripts. The repair is to recreate the original link shown at the top (sudo ln -s python3.12 /usr/bin/python3). Better: never touch /usr/bin/python3; call python3.13 explicitly or use a venv. If you ever see "python not found" on Ubuntu, read python not found on Ubuntu fixed.

Option B: install Python 3.13 with uv

uv downloads a standalone CPython build into your home directory, without root and without touching the system:

$ curl -LsSf https://astral.sh/uv/install.sh | sh
...
$ uv python install 3.13
 + cpython-3.13.16-linux-x86_64-gnu (python3.13)
warning: `/root/.local/bin` is not on your PATH. ...

$ uv python list --only-installed
cpython-3.13.16-linux-x86_64-gnu    /usr/bin/python3.13
cpython-3.13.16-linux-x86_64-gnu    /root/.local/share/uv/python/cpython-3.13-linux-x86_64-gnu/bin/python3.13
cpython-3.12.3-linux-x86_64-gnu     /usr/bin/python3.12

$ uv venv --python 3.13 uvenv; uvenv/bin/python --version
Creating virtual environment at: uvenv
Python 3.13.16
$ uv run --python 3.13 python -c 'import sys; print(sys.version)'
3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]

uv also lists the PPA and system interpreters it found. Note the PATH warning: add ~/.local/bin to PATH (the installer prints how). For developers this is the quickest way to install Python 3.13, and it also works on distributions without a PPA.

Option C: build Python 3.13 from source

$ sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev
$ curl -sO https://www.python.org/ftp/python/3.13.16/Python-3.13.16.tgz && tar xzf Python-3.13.16.tgz
$ cd Python-3.13.16 && ./configure --prefix=/usr/local && make -j$(nproc) && sudo make altinstall
configure rc=0
make rc=0 in 20 s
altinstall rc=0
$ ls /usr/local/bin/ | grep -E '^python|^pip'
pip3.13
python3.13
python3.13-config

$ /usr/local/bin/python3.13 -c 'import ssl, sqlite3, zlib, bz2, readline; print("ssl", ssl.OPENSSL_VERSION)'
ssl OpenSSL 3.0.13 30 Jan 2024

make altinstall installs only versioned names (python3.13, pip3.13); plain make install would also create /usr/local/bin/python3, which then shadows the system Python in PATH. The build took 20 seconds on 20 cores without --enable-optimizations (add it for a faster interpreter and a much longer build). Check the end of the build log for modules that were skipped because a -dev package was missing:

The necessary bits to build these optional modules were not found:
_dbm                      _gdbm                     _tkinter

$ which -a python3.13
/usr/local/bin/python3.13
/usr/bin/python3.13
/bin/python3.13

With both the PPA and the source build installed, /usr/local/bin comes first in PATH. Keep one method per machine to avoid confusion.

Which way to install Python 3.13?

MethodRootUpdatesGood for
deadsnakes PPAyeswith aptservers, system-wide 3.13
uvnouv python installdevelopers, CI, several versions
source + altinstallyes (install)manual rebuildcustom builds, no internet PPA
Debian 13 / newer distro-with apt3.13 is the default python3

Whichever way you install Python 3.13, leave /usr/bin/python3 alone and use venvs. Release notes and downloads are on python.org.

Comments

Popular posts from this blog

How to Play Minecraft Bedrock Edition on Linux: A Comprehensive Guide for Tech Professionals

The Ultimate Guide: How to Set Up DXVK in Wine on Linux for Enhanced Gaming Performance

Linux desktop frozen? My 5 go-to tricks to try - before forcing a hard reboot