How to Install Python 3.10 on Ubuntu (26.04, 24.04, 22.04)

Last updated Friday, February 27, 2026 12:11 pm 24 min read 1 comment

Python 3.10 introduced structural pattern matching, stricter type union syntax, and improved error messages that many production frameworks and data-science toolchains still depend on. To install Python 3.10 on Ubuntu, pick the path that matches your release: Ubuntu 22.04 LTS includes python3.10 in its default repositories, Ubuntu 24.04 LTS provides it through the Deadsnakes PPA, and Ubuntu 26.04 LTS currently needs a source build because the PPA does not yet publish a resolute Release file.

The interpreter sits alongside Ubuntu’s system Python without touching /usr/bin/python3, so apt and OS tooling keep working. The walkthrough below covers every install path plus pip, python3.10-venv virtual environments, safe update-alternatives switching, troubleshooting, and clean removal. Upstream security patches continue through October 2026, and Canonical maintains the Ubuntu 22.04 LTS package through mid-2032.

Install Python 3.10 on Ubuntu

Pick the installation method that matches your Ubuntu release and deployment needs. The following table compares each approach so you can decide which delivers the most reliable updates and compatibility.

MethodChannelVersionUpdatesBest For
APT (Ubuntu 22.04 repos)Ubuntu ReposUbuntu-maintained 3.10.x (LTS-patched)Automatic via apt upgradeUbuntu 22.04 LTS systems (recommended)
APT (Deadsnakes PPA)Deadsnakes PPA3.10.x (community-built)Automatic via apt upgrade (PPA cadence)Ubuntu 24.04 LTS, or newer releases only after Deadsnakes publishes that codename
Build from sourcePython.org SourceYou choose (latest 3.10.x recommended)Manual rebuild for updatesCustom prefixes, compile flags, or isolated installs

Whichever method you choose, never replace the default /usr/bin/python3 interpreter. Ubuntu’s package manager, desktop tools, and system utilities depend on the version that ships with the distribution.

These instructions cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. On Ubuntu 26.04 LTS, the Deadsnakes PPA currently returns a missing Release file for resolute, so use the source-build method. Ubuntu 24.04 LTS can install Python 3.10 from the Deadsnakes PPA, while Ubuntu 22.04 LTS installs Python 3.10 directly from the official repositories. Ubuntu 20.04 LTS is outside this guide’s supported scope; upgrade to a supported Ubuntu LTS release before using these steps on production systems.

Update Ubuntu Packages Before Installing Python 3.10

Refresh the package index first so APT sees the latest repository metadata and package versions.

sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:2 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:3 http://security.ubuntu.com/ubuntu noble-security InRelease
Reading package lists... Done

Applying outstanding upgrades (sudo apt upgrade) before installing Python prevents dependency conflicts, especially on servers that have not been updated recently.

Your user account needs sudo privileges to run administrative commands. See how to add a user to sudoers on Ubuntu if you receive “permission denied” errors.

Install Python 3.10 from Ubuntu 22.04 LTS Repositories

Ubuntu 22.04 LTS, elementary OS 7, Pop!_OS 22.04, and other distributions based on Ubuntu 22.04 LTS already include python3.10 in their main repositories. Install the interpreter, virtual environment module, and legacy Distutils support in a single command:

sudo apt install python3.10 python3.10-venv python3-distutils

On Ubuntu 22.04 LTS, the python3-distutils package provides Distutils for the system Python (which is 3.10). There is no separate python3.10-distutils package in the default repositories. The Deadsnakes PPA on Ubuntu 24.04 LTS does include version-specific packages like python3.10-distutils.

Before installing, you can verify package availability and source using apt-cache policy:

apt-cache policy python3.10
python3.10:
  Installed: 3.10.12-1~22.04.14
  Candidate: 3.10.12-1~22.04.14
  Version table:
 *** 3.10.12-1~22.04.14 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     3.10.4-3 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages

Verify the interpreter matches the expected release:

python3.10 --version
Python 3.10.12

The exact patch version depends on your Ubuntu release and update level. Ubuntu 22.04 LTS typically reports 3.10.12 with Canonical security patches.

Run a quick smoke test to ensure core modules load correctly:

python3.10 -c "import ssl, sqlite3; print('Python 3.10 ready on Ubuntu')"
Python 3.10 ready on Ubuntu

Install Python 3.10 on Ubuntu 24.04 LTS via Deadsnakes PPA

Ubuntu 24.04 LTS ships Python 3.12 by default, so you typically rely on the community-maintained Deadsnakes PPA for python3.10 packages. Deadsnakes availability can change over time, so always verify the candidate version shown by APT before installing.

If add-apt-repository is missing on minimal servers or containers, install the helper package first:

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:2 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:3 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:4 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble InRelease
Reading package lists... Done

Optional: Configure APT Pinning for the Deadsnakes PPA

On shared servers or general-purpose workstations, optional APT pinning reduces the chance of installing unrelated packages from the Deadsnakes PPA. This keeps Python 3.10 packages preferred while the rest of the PPA stays deprioritized.

cat <<EOF | sudo tee /etc/apt/preferences.d/python310-deadsnakes-pin
Package: *
Pin: release o=LP-PPA-deadsnakes
Pin-Priority: 100

Package: python3.10*
Pin: release o=LP-PPA-deadsnakes
Pin-Priority: 700
EOF

Verify the pin before installation. APT should list pinned python3.10* packages at priority 700:

apt-cache policy | grep -A6 "Pinned packages:"
Pinned packages:
     python3.10 -> 3.10.19-1+noble1 with priority 700
     python3.10-venv -> 3.10.19-1+noble1 with priority 700
     python3.10-gdbm -> 3.10.19-1+noble1 with priority 700

Use a preferences filename without version dots, such as python310-deadsnakes-pin. In testing, APT ignored python3.10-deadsnakes-pin but loaded the dotless filename correctly.

Verify that APT recognizes the PPA before proceeding with installation. If you enabled pinning, the package priority changes from 500 to 700:

apt-cache policy python3.10
python3.10:
  Installed: (none)
  Candidate: 3.10.19-1+noble1
  Version table:
      3.10.19-1+noble1 500
          500 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble/main amd64 Packages

APT now recognizes Python 3.10 from the Deadsnakes PPA. Install the interpreter and essential modules:

sudo apt install python3.10 python3.10-venv python3.10-dev

Deadsnakes packages are community-maintained. Monitor security advisories and be prepared to hold updates temporarily or rebuild from source yourself if a critical CVE appears before patched binaries land in the PPA.

Confirm the interpreter reports the expected version:

python3.10 --version
Python 3.10.19

Optional Python 3.10 Modules for Debugging and Development on Ubuntu

Install additional modules when your workflow demands debugging tools, GUI bindings, or compatibility layers:

python3.10-dbg provides debugging symbols for profiling, crash analysis, or gdb attachments.

sudo apt install python3.10-dbg

python3.10-dev adds headers and static libraries required to compile native extensions.

sudo apt install python3.10-dev

python3.10-venv enables the built-in venv module for per-project environments.

sudo apt install python3.10-venv

Distutils provides the legacy build system still used by older setup.py scripts. The package name differs by distribution source:

Ubuntu 22.04 LTS (default repos):

sudo apt install python3-distutils

Ubuntu 24.04 LTS (Deadsnakes PPA):

sudo apt install python3.10-distutils

python3.10-lib2to3 installs modernization tools for porting Python 2 code to Python 3.

sudo apt install python3.10-lib2to3

python3.10-gdbm provides GNU dbm bindings for lightweight key-value storage.

sudo apt install python3.10-gdbm

python3.10-tk installs Tkinter for GUI applications.

sudo apt install python3.10-tk

Combine packages into one apt invocation to save time:

sudo apt install python3.10-venv python3.10-dev python3.10-gdbm python3.10-tk

Only install Distutils or lib2to3 when older build scripts require them. Modern projects rely on pip, setuptools, wheel, or pyproject.toml-based tooling instead.

Compile Python 3.10 from Source on Ubuntu

Compile Python 3.10 manually when you need Link Time Optimization, custom prefixes, or independent upgrade cycles. Source builds install alongside Ubuntu’s system Python without overwriting /usr/bin/python3. This is also the only option on Ubuntu 26.04 LTS until the Deadsnakes PPA publishes resolute packages.

Download the Latest Python 3.10.x Source Tarball

Download the latest 3.10.x release directly from python.org using the wget command and extract the archive. Create a dedicated build directory in your home folder to keep your workspace organized:

mkdir -p ~/python3.10-build && cd ~/python3.10-build
PYTHON_VERSION=$(wget -qO- https://www.python.org/downloads/source/ | grep -oE 'Python-3\.10\.[0-9]+\.tar\.xz' | sort -V | tail -1 | grep -oE '3\.10\.[0-9]+')
wget "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz"
wget "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz.asc"

The commands above auto-detect the latest Python 3.10.x tarball from the Python.org source downloads page. If PYTHON_VERSION is empty, visit the page directly and set the version manually before downloading. Ubuntu 26.04 LTS currently relies on this source-build path because the Deadsnakes PPA does not publish a resolute Release file.

Verify the Python 3.10 Source Download Signature

Python releases are signed by a release manager using GPG. Verifying the signature confirms the tarball originated from python.org and was not modified in transit. First, import the Python release signing keys:

gpg --keyserver hkps://keys.openpgp.org --recv-keys \
  A821E680E5FA6305 \
  64E628F8D684696D

These key IDs belong to Pablo Galindo Salgado and other Python release managers who sign 3.10.x releases. Now verify the signature:

gpg --verify "Python-${PYTHON_VERSION}.tar.xz.asc" "Python-${PYTHON_VERSION}.tar.xz"
gpg: Signature made Tue Oct  9 12:30:00 2025 UTC
gpg:                using RSA key 64E628F8D684696D
gpg: Good signature from "Pablo Galindo Salgado <Pablogsal@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!

A “Good signature” message confirms authenticity. The “not certified with a trusted signature” warning appears because you have not personally certified the key; this is normal for first-time verification. If verification fails or shows “BAD signature”, delete the download and try again from python.org.

Extract the verified source tarball:

tar -xf "Python-${PYTHON_VERSION}.tar.xz"
cd "Python-${PYTHON_VERSION}"

Install Python 3.10 Build Dependencies on Ubuntu

Before compiling, install the libraries required for SSL, compression, readline, Tk, and UUID support:

sudo apt install -y build-essential zlib1g-dev libgdbm-dev libnss3-dev \
libssl-dev libsqlite3-dev libreadline-dev libffi-dev libbz2-dev liblzma-dev uuid-dev \
tk-dev pkg-config libncurses-dev

The libncurses-dev package provides terminal handling libraries and works on all supported Ubuntu LTS releases. If any optional module fails to build after compilation, install the corresponding -dev package and rebuild.

Configure and Build Python 3.10

Compile Python with optimization flags. The following example installs Python under /usr/local/python3.10 to avoid overwriting your system interpreter:

./configure --enable-shared --enable-optimizations --with-ensurepip=install --prefix=/usr/local/python3.10
make -j"$(nproc)"
sudo make altinstall

A successful configure stage ends with output similar to:

config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating pyconfig.h
creating Makefile

Using make altinstall instead of make install keeps /usr/bin/python3 untouched while adding /usr/local/python3.10/bin/python3.10. The --enable-shared flag builds libpython3.10.so, which matches the linker-cache steps in the next section.

Register Python 3.10 Libraries and Test the Source Build

After compilation completes, point the dynamic linker at your custom installation, reload the cache, and create a convenience symlink:

echo '/usr/local/python3.10/lib' | sudo tee /etc/ld.so.conf.d/python3.10.conf
sudo ldconfig
sudo ln -sf /usr/local/python3.10/bin/python3.10 /usr/local/bin/python3.10

Confirm the linker cache and symlink were registered correctly:

ldconfig -p | grep "libpython3.10.so.1.0"
ls -l /usr/local/bin/python3.10
libpython3.10.so.1.0 (libc6,x86-64) => /usr/local/python3.10/lib/libpython3.10.so.1.0
lrwxrwxrwx 1 root root 37 /usr/local/bin/python3.10 -> /usr/local/python3.10/bin/python3.10

Verify the build and confirm critical modules compiled successfully:

python3.10 --version
python3.10 -c "import ssl, sqlite3, bz2; print('Source build is healthy')"
Python 3.10.19
Source build is healthy

If the second command fails, reinstall the missing -dev packages, rerun ./configure, and rebuild the installation.

Create an Update Script for Source-Compiled Python 3.10

When you compile Python from source, security updates require manual recompilation. The following script automates the download, build, and installation process so you can keep your source-compiled Python 3.10 current with the latest maintenance releases.

Create a dedicated build directory in your home folder and save the update script there:

mkdir -p ~/python3.10-build
nano ~/python3.10-build/update-python3.10.sh

Add the following script content. The script checks for the latest Python 3.10.x release, compares it to your installed version, and recompiles only when a newer version is available:

#!/usr/bin/env bash
set -euo pipefail

# Configuration
INSTALL_PREFIX="/usr/local/python3.10"
BUILD_DIR="$HOME/python3.10-build"
LOG_FILE="${BUILD_DIR}/update.log"

# Check for required tools
for cmd in gcc make wget curl tar grep sort nproc; do
    if ! command -v "$cmd" >/dev/null 2>&1; then
        echo "Error: $cmd is required but not installed."
        echo "Install prerequisites first, then rerun this script."
        exit 1
    fi
done

mkdir -p "$BUILD_DIR"

# Get current installed version (if any)
CURRENT_VERSION="none"
if [ -x "${INSTALL_PREFIX}/bin/python3.10" ]; then
    CURRENT_VERSION=$("${INSTALL_PREFIX}/bin/python3.10" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || true)
    CURRENT_VERSION=${CURRENT_VERSION:-none}
fi

# Fetch latest Python 3.10.x version from python.org downloads page
echo "Checking for latest Python 3.10.x version..."
LATEST_VERSION=$(curl -fsSL https://www.python.org/downloads/source/ | grep -oE 'Python-3\.10\.[0-9]+\.tar\.xz' | sort -V | tail -1 | grep -oE '3\.10\.[0-9]+')

if [ -z "${LATEST_VERSION:-}" ]; then
    echo "Error: could not detect the latest 3.10.x release from python.org"
    exit 1
fi

echo ""
echo "Current installed version: ${CURRENT_VERSION}"
echo "Latest available version:  ${LATEST_VERSION}"
echo ""

if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
    echo "Python 3.10 is already up to date."
    exit 0
fi

read -p "Continue with update? (y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo "Update cancelled."
    exit 0
fi

echo "Updating to ${LATEST_VERSION}..."
echo "$(date -Is): Starting update to ${LATEST_VERSION}" >> "$LOG_FILE"

cd "$BUILD_DIR"

# Clean previous builds in the dedicated build directory
rm -rf Python-3.10.*

# Download, extract, build
echo "Downloading Python ${LATEST_VERSION}..."
wget -q "https://www.python.org/ftp/python/${LATEST_VERSION}/Python-${LATEST_VERSION}.tar.xz"
echo "Extracting source code..."
tar -xf "Python-${LATEST_VERSION}.tar.xz"
rm -f "Python-${LATEST_VERSION}.tar.xz"

cd "Python-${LATEST_VERSION}"
echo "Configuring build (this takes a few minutes with optimizations)..."
./configure --enable-shared --enable-optimizations --with-ensurepip=install --prefix="$INSTALL_PREFIX"
echo "Compiling Python (this may take 10-30 minutes)..."
make -j"$(nproc)"
echo "Installing Python (requires sudo)..."
sudo make altinstall
echo "Refreshing linker cache..."
sudo ldconfig

# Verify
NEW_VERSION=$("${INSTALL_PREFIX}/bin/python3.10" --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "$(date -Is): Updated to ${NEW_VERSION}" >> "$LOG_FILE"
echo ""
echo "Successfully updated to Python ${NEW_VERSION}"

Save the file by pressing Ctrl+O, then Enter, then exit with Ctrl+X. Make the script executable:

chmod +x ~/python3.10-build/update-python3.10.sh

Run the script manually when you want to check for updates:

~/python3.10-build/update-python3.10.sh

A successful update run produces output similar to:

Checking for latest Python 3.10.x version...

Current installed version: 3.10.18
Latest available version:  3.10.19

Continue with update? (y/n) y
Updating to 3.10.19...
Downloading Python 3.10.19...
Extracting source code...
Configuring build (this takes a few minutes with optimizations)...
Compiling Python (this may take 10-30 minutes)...
Installing Python (requires sudo)...
[sudo] password for user:
Refreshing linker cache...

Successfully updated to Python 3.10.19

Avoid automating this with cron. Compilation can fail due to missing dependencies, failed tests, or network issues. Always run the script manually so you can monitor the output and address problems before they affect your system.

Install Pip for Python 3.10 on Ubuntu

Pip availability depends on how you installed Python 3.10. Use the method below that matches your Ubuntu release and installation path. For broader pip usage guidance, see our Python pip installation guide for Ubuntu.

Install Pip via APT for Ubuntu 22.04 LTS Python 3.10

On Ubuntu 22.04 LTS, the python3-pip package targets the default Python 3.10 interpreter and keeps pip updated through APT:

sudo apt install python3-pip python3.10-venv

Verify pip is available through the Python 3.10 interpreter:

python3.10 -m pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

Install Pip with ensurepip for Deadsnakes or Source-Built Python 3.10

If you installed Python 3.10 from the Deadsnakes PPA on Ubuntu 24.04 LTS or compiled Python 3.10 from source, use ensurepip to bootstrap pip for that interpreter:

python3.10 -m ensurepip --upgrade
python3.10 -m pip --version
pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.10)

Ubuntu 22.04 LTS disables ensurepip for the default system Python 3.10 and prints a Debian/Ubuntu policy message instead. Use the APT method above on 22.04, then run python3.10 -m pip commands normally.

Pip versions vary by Ubuntu release and installation method. APT tracks Canonical’s packaging cycle, while ensurepip and source builds use the pip version bundled with your Python 3.10 build or bootstrap wheel set.

Bootstrap Pip with get-pip.py for Python 3.10

Use the get-pip.py bootstrap script only when APT or ensurepip is not practical, such as custom offline workflows or recovery on a broken pip installation:

wget https://bootstrap.pypa.io/get-pip.py
python3.10 get-pip.py
rm get-pip.py

This approach installs pip, setuptools, and wheel side by side. Download a fresh copy of the script each time you use it.

Manage Packages with python3.10 -m pip

Always call pip through the Python 3.10 interpreter to avoid cross-version confusion:

python3.10 -m pip install package_name
python3.10 -m pip install --upgrade package_name
python3.10 -m pip uninstall package_name

Replace package_name with libraries such as numpy, fastapi, or ansible-core. This keeps package management tied to Python 3.10 instead of Ubuntu’s default interpreter.

PEP 668 “externally managed” errors on Ubuntu 24.04 LTS and 26.04 LTS primarily affect the default system interpreter (python3). In testing, python3.10 from the Deadsnakes PPA did not trigger that error, but virtual environments are still the safest option for project installs.

Set Up Python 3.10 Virtual Environments on Ubuntu

Virtual environments prevent package conflicts between projects by providing isolated site-packages directories. For a detailed walkthrough of environment management, see our Python virtual environment guide for Ubuntu.

Create a Python 3.10 Virtual Environment

First, create a dedicated directory for your environments (for example ~/venvs) and provision a new one with python3.10:

python3.10 -m venv ~/venvs/py310

Replace ~/venvs/py310 with any path meaningful to your workflow.

Activate the Python 3.10 Virtual Environment

Activate the environment so your shell points python and pip to the local installation:

source ~/venvs/py310/bin/activate

The shell prompt changes to indicate the active environment:

(py310) user@hostname:~$

Install packages as needed while the environment remains active.

Deactivate the Python 3.10 Virtual Environment

When finished, exit the virtual environment by running:

deactivate

The shell returns to the system Python context, ensuring new sessions do not inherit the environment accidentally.

Switch Between Python Versions on Ubuntu

Use the update-alternatives framework when you need to change which interpreter launches when you type python. This approach keeps /usr/bin/python3 untouched, preserving system scripts that depend on Ubuntu’s default version.

Register only the interpreters already installed on your system. The binary path differs depending on how you installed Python 3.10:

  • APT-installed (Ubuntu 22.04 or Deadsnakes PPA): /usr/bin/python3.10
  • Source-compiled: /usr/local/bin/python3.10 (via symlink) or /usr/local/python3.10/bin/python3.10

For APT-installed interpreters on Ubuntu 24.04 LTS (Python 3.10 from Deadsnakes alongside the default Python 3.12):

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 4
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 5

For source-compiled Python 3.10 (using the symlink created during installation):

sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 4

Once you have registered each interpreter, select the default:

sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.12      5         auto mode
  1            /usr/bin/python3.10      4         manual mode
  2            /usr/bin/python3.12      5         manual mode

Press <enter> to keep the current choice[*], or type selection number:

Only adjust /usr/bin/python (the legacy Python 2 shim). Leave /usr/bin/python3 at the system default to avoid breaking apt, cloud-init, or other distribution utilities. If /usr/bin/python does not exist, install the python-is-python3 package first or skip update-alternatives entirely.

Troubleshoot Python 3.10 Installation Issues on Ubuntu

APT Reports “Unable to Locate Package python3.10”

This error appears when the active APT sources do not include a python3.10 package. On Ubuntu 24.04 LTS and newer, Python 3.10 is not in the default repositories, so you must add the Deadsnakes PPA first:

sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install python3.10

On Ubuntu 22.04 LTS, python3.10 is in the default repositories. If you still see this error, your package index may be outdated or corrupted. Refresh it and retry:

sudo apt update
apt-cache policy python3.10
python3.10:
  Installed: (none)
  Candidate: 3.10.12-1~22.04.14
  Version table:
     3.10.12-1~22.04.14 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages

The apt-cache policy output shows whether APT recognizes the package and which repository provides it. If no candidate version appears, check your /etc/apt/sources.list to confirm the main component is enabled.

Missing Development Headers During Python 3.10 Compilation on Ubuntu

The configure script may report warnings about missing optional libraries when development headers are not installed. While Python will compile successfully, certain standard library modules like _ssl, _bz2, or _sqlite3 will be unavailable. Review the configure output carefully:

./configure --enable-shared --enable-optimizations --with-ensurepip=install --prefix=/usr/local/python3.10 2>&1 | grep "disabled"
checking for stdlib extension module _ssl... missing
checking for stdlib extension module _sqlite3... missing

This command displays all disabled modules. Additionally, after running make, check for “Failed to build these modules” messages near the end of the compilation output. Install the corresponding -dev packages, then run ./configure and make again to rebuild with full module support.

Source Build Fails with Disk Quota Exceeded in /tmp on Ubuntu

On some Ubuntu VMs, /tmp is mounted as a small tmpfs. Python 3.10 source builds with --enable-optimizations can exhaust that temporary space during compilation even when the root filesystem still has free disk space.

/tmp/cc*.s: Fatal error: ... No space left on device
... error writing ...: Disk quota exceeded

Create a writable temp directory in your home folder and rerun the build with TMPDIR:

mkdir -p ~/tmp
TMPDIR=$HOME/tmp make -j"$(nproc)"
sudo make altinstall

Verify that the rebuilt interpreter starts correctly before continuing:

python3.10 --version
Python 3.10.19

Shared Library Linking Errors for Source-Built Python 3.10 on Ubuntu

When running python3.10 after a shared-library source build, you may see a linker error if the system has not registered libpython3.10.so.1.0 yet.

python3.10: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

First verify the shared library exists and note the path:

find /usr/local -name "libpython3.10.so*"
/usr/local/python3.10/lib/libpython3.10.so.1.0

Register the library path and refresh the linker cache:

echo "/usr/local/python3.10/lib" | sudo tee /etc/ld.so.conf.d/python3.10.conf
sudo ldconfig

Verify the interpreter starts correctly after refreshing the cache:

python3.10 --version
Python 3.10.19

PIP Externally-Managed Environment Errors on Ubuntu

On Ubuntu 24.04 LTS and 26.04 LTS, pip blocks installs to the default system interpreter (python3) without a virtual environment. This does not usually affect Python 3.10 installed from the Deadsnakes PPA or a source build.

error: externally-managed-environment

This environment is externally managed
... pass --break-system-packages ...

Create a virtual environment instead of bypassing protections:

python3 -m venv myproject_env
source myproject_env/bin/activate
pip install package-name

Use --break-system-packages only in disposable environments or when you understand the risk to the system Python environment:

python3 -m pip install --break-system-packages package-name

APT Breaking After Installing Python 3.10 PPA on Ubuntu

If apt update or apt install fails with Python-related errors after adding the Deadsnakes PPA, the /usr/bin/python3 symlink may have been changed. A common error looks like:

ModuleNotFoundError: No module named 'apt_pkg'

Check the /usr/bin/python3 symlink:

ls -la /usr/bin/python3

Expected output by Ubuntu release:

Ubuntu 22.04 LTS:

lrwxrwxrwx 1 root root 10 /usr/bin/python3 -> python3.10

Ubuntu 24.04 LTS:

lrwxrwxrwx 1 root root 10 /usr/bin/python3 -> python3.12

Ubuntu 26.04 LTS:

lrwxrwxrwx 1 root root 10 /usr/bin/python3 -> python3.13

If the symlink points to the wrong interpreter, restore the correct target for your release or reinstall python3-minimal so dpkg restores the shipped files:

# 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

# Ubuntu 26.04 LTS
sudo ln -sf /usr/bin/python3.13 /usr/bin/python3

# Alternative repair path
sudo apt install --reinstall python3-minimal

If you are running a minimal container where python3-minimal is not installed, install it first. Additionally, always invoke Python 3.10 explicitly using python3.10 rather than modifying the python3 symlink.

Python 3.10 ensurepip Is Disabled on Ubuntu 22.04

Running python3.10 -m ensurepip on Ubuntu 22.04 LTS prints a policy warning instead of bootstrapping pip because ensurepip is disabled for the system interpreter by Debian/Ubuntu packaging policy:

ERROR: ensurepip is disabled in Debian/Ubuntu for the system python.

Install pip through APT instead, which targets the default Python 3.10 interpreter on 22.04:

sudo apt install python3-pip
python3.10 -m pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

On Ubuntu 24.04 LTS with the Deadsnakes PPA or on source-compiled builds, ensurepip works normally because those interpreters are not managed by APT.

Python 3.10 Virtual Environment Creation Fails on Ubuntu

When python3.10 -m venv fails with “ensurepip is not available” or similar errors, the python3.10-venv package is missing. Install it explicitly:

sudo apt install python3.10-venv

For source-compiled installations, ensure you configured with --with-ensurepip=install before running make. If you skipped this flag, bootstrap pip manually using the get-pip.py script as described in the pip installation section.

Update or Remove Python 3.10 on Ubuntu

Keep Python 3.10 patched just like any other package. Use apt for repository builds and manual cleanup for source installations.

Update Python 3.10 Packages on Ubuntu

sudo apt update
sudo apt install --only-upgrade python3.10 python3.10-venv python3.10-dev

This upgrades only the Python 3.10 packages you installed, without pulling in unrelated system upgrades. If you prefer to update everything at once, use sudo apt upgrade instead.

Remove Python 3.10 Packages on Ubuntu

If a project no longer needs Python 3.10, remove only copies installed from the PPA or manual builds.

Do not purge python3.10 on Ubuntu 22.04 LTS or derivatives where it is the default system interpreter. Removing it breaks apt, cloud-init, and desktop utilities. The following commands are safe for Ubuntu 24.04 LTS and newer when Python 3.10 was added from the Deadsnakes PPA as an additional interpreter.

sudo apt remove --purge python3.10 python3.10-venv python3.10-dev
sudo apt autoremove --purge

Additionally, remove the Deadsnakes PPA and the optional pinning file if your system no longer requires Python 3.10 packages:

sudo add-apt-repository --remove ppa:deadsnakes/ppa -y
sudo rm -f /etc/apt/preferences.d/python310-deadsnakes-pin
sudo apt update

Confirm the PPA no longer exists in your APT sources:

grep -R "deadsnakes" /etc/apt/sources.list.d/ || echo "No Deadsnakes entries found"
No Deadsnakes entries found

For source builds, delete the installation directory and ld.so entry. When you compiled with the default prefix (/usr/local), remove these files:

The following commands permanently delete your source-compiled Python 3.10 installation under /usr/local/python3.10, plus any third-party modules you installed into that prefix. Back up anything you need before continuing.

sudo rm -rf /usr/local/python3.10
sudo rm -f /usr/local/bin/python3.10
sudo rm -f /etc/ld.so.conf.d/python3.10.conf
sudo ldconfig
rm -rf ~/python3.10-build

If you used a custom prefix like --prefix=/opt/python3.10, simply remove that directory:

This permanently deletes the source-compiled Python 3.10 prefix. If you created a convenience symlink (for example /usr/local/bin/python3.10), remove it as well.

sudo rm -rf /opt/python3.10
sudo rm -f /usr/local/bin/python3.10
sudo ldconfig

Remove Python 3.10 update-alternatives Entries

If you configured update-alternatives for Python version switching, remove the python3.10 entry. Use the same path you registered originally:

For APT-installed Python 3.10:

sudo update-alternatives --remove python /usr/bin/python3.10

For source-compiled Python 3.10:

sudo update-alternatives --remove python /usr/local/bin/python3.10

Verify the removal completed successfully:

sudo update-alternatives --list python
/usr/bin/python3.12

If Python 3.10 was the only registered alternative, the command prints update-alternatives: error: no alternatives for python instead.

When to Choose Python 3.10 Over Newer Versions on Ubuntu

Compare Python Releases for Ubuntu

Use this reference comparison after installation when you need to evaluate whether Python 3.10 still matches your compatibility, support, and feature requirements.

Python VersionAvailability on UbuntuChoose It WhenTrade-offs
Install Python 3.8 on UbuntuDeadsnakes PPA or source build onlyLegacy applications pinned to EOL runtimes, transitional migrations, compatibility testingSecurity fixes ended October 2024, limited upstream support, container isolation recommended
Python 3.10Ubuntu 22.04 LTS default, Deadsnakes PPA for 24.04 LTS, source build on 26.04 LTS until PPA support landsProduction fleets that require LTS security coverage through 2026, tools expecting pattern matching or 3.10-specific ABIReceives fewer new features, Ubuntu 24.04+ users need a PPA or source build, some libraries now target 3.11+
Install Python 3.11 on UbuntuDeadsnakes PPA (where available) or source buildPerformance-focused workloads and teams that want newer language/runtime features (for example exception groups and TOML support)Not the default interpreter on Ubuntu LTS releases, some vendor SDKs still validate primarily against 3.10
Install Python 3.12 on UbuntuUbuntu 24.04 LTS default, Deadsnakes PPA for 22.04 LTSNew deployments, developers targeting f-string upgrades, continued language/runtime improvementsNewer runtime may expose compatibility gaps in older modules, Ubuntu 22.04 LTS systems may rely on Deadsnakes PPA
Install Python 3.13 on UbuntuDeadsnakes PPA (where published) or source buildAdopting the latest typing and startup improvements, validating newer interpreter behavior, preparing for future upgradesNot in Ubuntu repositories, community packages lack guaranteed security SLAs, some third-party wheels may lag initial releases
Install Python 3.14 on UbuntuDeadsnakes PPA (where published) or source buildEarly adopter testing and benchmarking, validating the newest runtime features as they landNot in Ubuntu repositories, PPA refresh cadence may lag security fixes, third-party wheels can trail initial releases

When to Stay on Python 3.10 on Ubuntu

Stick with Python 3.10 when you prioritize predictable LTS maintenance, when vendor tools certify only against Ubuntu 22.04 LTS defaults, or when your automation pipeline already consumes 3.10 wheel builds. Enterprise software such as Ansible playbooks, data science pipelines, and cluster orchestration tooling often hardcode python3.10 paths, and Canonical provides Extended Security Maintenance for Ubuntu 22.04 LTS through mid-2032, so python3.10 receives patched packages even after upstream EOL. Install a newer release for greenfield projects or workloads that benefit from the performance and syntax enhancements in Python 3.11 on Ubuntu, Python 3.12 on Ubuntu, Python 3.13 on Ubuntu, or Python 3.14 on Ubuntu.

Frequently Asked Questions About Python 3.10 on Ubuntu

Is Python 3.10 still supported?

Python 3.10 receives upstream security updates through October 2026. After that date, CPython no longer publishes patches, but Canonical continues to ship security fixes for python3.10 on Ubuntu 22.04 LTS through Extended Security Maintenance until mid-2032.

Can Python 3.10 and Python 3.12 coexist on Ubuntu?

Yes. Ubuntu supports multiple interpreter versions side by side. Install Python 3.10 from the Deadsnakes PPA or compile from source while keeping the default python3 symlink pointed at the system interpreter. Use python3.10 and python3.12 explicitly or manage defaults with update-alternatives.

Should I use the Deadsnakes PPA or compile from source on Ubuntu 24.04?

Use the Deadsnakes PPA for automatic security updates and simpler maintenance. Compile from source only when you need custom compile flags, Link Time Optimization, or an isolated prefix that the PPA cannot provide.

Will removing Python 3.10 break Ubuntu 22.04?

Yes. On Ubuntu 22.04 LTS, Python 3.10 is the default system interpreter. Removing it breaks apt, cloud-init, and desktop utilities. Only remove Python 3.10 on Ubuntu 24.04 LTS and newer where it was added as a secondary interpreter from the Deadsnakes PPA or a source build.

What is the default Python version on Ubuntu 22.04?

The default Python version on Ubuntu 22.04 LTS is Python 3.10 (python3.10, typically patch level 3.10.12). The python3 symlink and all system tools point to this version. Canonical provides security fixes through Extended Security Maintenance until mid-2032.

Is Python 3.10 available in Ubuntu 24.04 default repositories?

No. Ubuntu 24.04 LTS ships Python 3.12 as its default interpreter and does not include python3.10 in the official repositories. To install Python 3.10 on Ubuntu 24.04, add the Deadsnakes PPA with sudo add-apt-repository ppa:deadsnakes/ppa and then run sudo apt install python3.10.

Where is the python3.10-distutils package on Ubuntu?

On Ubuntu 22.04 LTS, Distutils for Python 3.10 is provided by the python3-distutils package (not python3.10-distutils) because 3.10 is the system Python. On Ubuntu 24.04 LTS with the Deadsnakes PPA, the version-specific python3.10-distutils package is available. Note that Distutils is deprecated since Python 3.12; modern projects should use setuptools or pyproject.toml-based build systems instead.

Can I install Python 3.10 on Ubuntu 20.04?

Yes, but Ubuntu 20.04 LTS reached standard support end-of-life in April 2025. The Deadsnakes PPA still publishes python3.10 for focal, so sudo add-apt-repository ppa:deadsnakes/ppa followed by sudo apt install python3.10 works. However, upgrading to Ubuntu 22.04 LTS or newer is strongly recommended because 22.04 ships Python 3.10 as the default interpreter with full Canonical security maintenance.

Why does ensurepip say it is disabled on Ubuntu 22.04?

Ubuntu 22.04 LTS disables ensurepip for the system Python 3.10 by Debian/Ubuntu policy. Running python3.10 -m ensurepip prints a warning instead of bootstrapping pip. Install pip through APT with sudo apt install python3-pip, which targets the default Python 3.10 interpreter. On Ubuntu 24.04 LTS with the Deadsnakes PPA or on source builds, ensurepip works normally because those interpreters are not managed by APT.

How do I downgrade from Python 3.12 to Python 3.10 on Ubuntu 24.04?

You do not need to downgrade. Install Python 3.10 alongside Python 3.12 by adding the Deadsnakes PPA (sudo add-apt-repository ppa:deadsnakes/ppa) and running sudo apt install python3.10. Use python3.10 explicitly for workloads that require it while keeping python3 pointed at the system Python 3.12. Never replace the /usr/bin/python3 symlink.

Conclusion

Python 3.10 is running alongside Ubuntu’s default interpreter on 26.04 LTS, 24.04 LTS, or 22.04 LTS with pip, virtual environments, and update-alternatives switching in place. Keep the python3 symlink at the system default, use python3.10 explicitly for legacy workloads, and run the update script or apt install --only-upgrade periodically to stay current on security patches.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

1 thought on “How to Install Python 3.10 on Ubuntu (26.04, 24.04, 22.04)”

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: