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, use the default Ubuntu package on 22.04 LTS or the Deadsnakes PPA on 26.04 LTS and 24.04 LTS.
The interpreter sits alongside Ubuntu’s system Python without touching /usr/bin/python3, so apt and OS tooling keep working. Upstream Python 3.10 security-only releases continue until October 2026, while Canonical keeps maintaining Ubuntu 22.04 LTS packages through the release’s extended maintenance window.
Install Python 3.10 on Ubuntu
Pick the installation method that matches your Ubuntu release and maintenance needs. The following table compares each approach before you run any commands.
| Method | Channel | Runtime Branch | Updates | Best For |
|---|---|---|---|---|
| APT (Ubuntu 22.04 repos) | Ubuntu Repos | Ubuntu-maintained 3.10.x | Through Ubuntu package updates | Ubuntu 22.04 LTS systems where Python 3.10 is the default interpreter |
| APT (Deadsnakes PPA) | Deadsnakes PPA | Community-built 3.10.x | Through APT after adding the PPA | Ubuntu 26.04 LTS and 24.04 LTS systems that need Python 3.10 beside the default interpreter |
| Build from source | Python.org FTP Source | Selected 3.10.x source release | Manual rebuilds | Custom prefixes, compile-time options, or isolated lab installs |
Whichever method you choose, never replace the package-owned /usr/bin/python3 interpreter, retarget it with update-alternatives, or purge the release-owned Python branch. Ubuntu tools such as apt, add-apt-repository, command-not-found, cloud-init, and desktop utilities expect the distro Python and its packaged modules to stay intact. Use python3.10, project virtual environments, or an explicit source-build path instead.
These instructions cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. Ubuntu 20.04 LTS is outside this workflow because its standard support window ended in April 2025; 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
sudoprivileges 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 uses Python 3.10 as its default python3 interpreter, so the main package comes from Ubuntu’s own 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,
python3-distutilsprovides Distutils for the system Python 3.10 interpreter. The package namepython3.10-distutilsis not available from Jammy’s default repositories; it is a Deadsnakes package name for newer Ubuntu releases.
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.15
Candidate: 3.10.12-1~22.04.15
Version table:
*** 3.10.12-1~22.04.15 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 26.04 or 24.04 via Deadsnakes PPA
Ubuntu 26.04 LTS ships Python 3.14 by default, and Ubuntu 24.04 LTS ships Python 3.12 by default. Use the community-maintained Deadsnakes PPA when you need Python 3.10 as an additional interpreter on either release.
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 resolute InRelease Hit:2 http://archive.ubuntu.com/ubuntu resolute-updates InRelease Hit:3 http://security.ubuntu.com/ubuntu resolute-security InRelease Hit:4 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute 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.20-1+resolute1 with priority 700
python3.10-venv -> 3.10.20-1+resolute1 with priority 700
python3.10-gdbm -> 3.10.20-1+resolute1 with priority 700
Use a preferences filename without version dots, such as
python310-deadsnakes-pin. APT can treat text after the final dot as a filename extension, so a dotless filename avoids silent preference-file skips.
Verify that APT recognizes the PPA before proceeding with installation. The release suffix changes by Ubuntu version; on Ubuntu 24.04 LTS, the same package currently uses a +noble1 suffix.
apt-cache policy python3.10
python3.10:
Installed: (none)
Candidate: 3.10.20-1+resolute1
Version table:
3.10.20-1+resolute1 700
700 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute/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 python3.10-distutils
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.20
Optional Python 3.10 Modules for Debugging and Development on Ubuntu
Install optional modules only when your workflow needs debugging symbols, native extension headers, virtual environments, GUI bindings, or older compatibility tooling. Package names differ because Ubuntu 22.04 LTS treats Python 3.10 as the system interpreter, while Deadsnakes publishes version-specific module packages for Ubuntu 26.04 LTS and 24.04 LTS.
| Need | Ubuntu 22.04 LTS Package | Ubuntu 26.04/24.04 Deadsnakes Package |
|---|---|---|
| Debug symbols | python3.10-dbg | python3.10-dbg |
| Development headers | python3.10-dev | python3.10-dev |
| Virtual environments | python3.10-venv | python3.10-venv |
| Legacy Distutils | python3-distutils | python3.10-distutils |
| lib2to3 tools | python3-lib2to3 | python3.10-lib2to3 |
| GNU dbm bindings | python3-gdbm | python3.10-gdbm |
| Tkinter GUI bindings | python3-tk | python3.10-tk |
On Ubuntu 22.04 LTS, install the system-Python module packages with:
sudo apt install python3.10-dbg python3.10-dev python3.10-venv python3-distutils python3-lib2to3 python3-gdbm python3-tk
On Ubuntu 26.04 LTS or 24.04 LTS after adding the Deadsnakes PPA, use the version-specific Python 3.10 module packages:
sudo apt install python3.10-dbg python3.10-dev python3.10-venv python3.10-distutils python3.10-lib2to3 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 custom prefixes, custom compile-time options, or an isolated interpreter that does not depend on a PPA. Source builds install alongside Ubuntu’s system Python without overwriting /usr/bin/python3.
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/ftp/python/ | grep -oE 'href="3\.10\.[0-9]+/"' | grep -oE '3\.10\.[0-9]+' | sort -V | tail -1)
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 stable Python 3.10.x directory from the Python.org FTP source listing. If
PYTHON_VERSIONis empty, visit that listing directly and set the version manually before downloading.
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: using RSA key CFDCA245B1043CF2A5F97865FFE87404168BD847 gpg: Good signature from "Pablo Galindo Salgado <pablogsal@gmail.com>" [unknown] gpg: WARNING: This key is not certified with a trusted signature! Primary key fingerprint: A035 C8C1 9219 BA82 1ECE A86B 64E6 28F8 D684 696D
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 download tools and libraries required for SSL, compression, readline, Tk, and UUID support:
sudo apt install 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 wget gpg xz-utils ca-certificates
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 under /usr/local/python3.10 to avoid overwriting your system interpreter:
./configure --enable-shared --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.20 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, signature verification, build, and installation process so you can keep your source-compiled Python 3.10 current with the latest maintenance releases.
First, check the version currently installed under the article’s source-build prefix:
/usr/local/python3.10/bin/python3.10 --version 2>/dev/null || echo "Source build not installed yet"
Python 3.10.19
Then resolve the latest stable Python 3.10.x source directory before building the helper. This keeps the lookup constrained to the 3.10 maintenance branch:
wget -qO- https://www.python.org/ftp/python/ | grep -oE 'href="3\.10\.[0-9]+/"' | grep -oE '3\.10\.[0-9]+' | sort -V | tail -1
3.10.20
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, verifies the downloaded tarball, and recompiles only when a newer version is available. Import the Python release signing keys from the verification section above before running it.
#!/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 lookup tools
for cmd in wget grep sort; 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 FTP listing
echo "Checking for latest Python 3.10.x version..."
LATEST_VERSION=$(wget -qO- https://www.python.org/ftp/python/ | grep -oE 'href="3\.10\.[0-9]+/"' | grep -oE '3\.10\.[0-9]+' | sort -V | tail -1)
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
# Check for build tools only when an update will run
for cmd in gcc make tar nproc gpg xz sudo; 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
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, verify, extract, build
echo "Downloading Python ${LATEST_VERSION}..."
wget -q "https://www.python.org/ftp/python/${LATEST_VERSION}/Python-${LATEST_VERSION}.tar.xz"
wget -q "https://www.python.org/ftp/python/${LATEST_VERSION}/Python-${LATEST_VERSION}.tar.xz.asc"
echo "Verifying source signature..."
gpg --verify "Python-${LATEST_VERSION}.tar.xz.asc" "Python-${LATEST_VERSION}.tar.xz"
echo "Extracting source code..."
tar -xf "Python-${LATEST_VERSION}.tar.xz"
rm -f "Python-${LATEST_VERSION}.tar.xz" "Python-${LATEST_VERSION}.tar.xz.asc"
cd "Python-${LATEST_VERSION}"
echo "Configuring build..."
./configure --enable-shared --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.19 Latest available version: 3.10.20 Continue with update? (y/n) y Updating to 3.10.20... Downloading Python 3.10.20... Verifying source signature... Extracting source code... Configuring build... 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.20
If the installed source build is already current, the helper exits without rebuilding:
Checking for latest Python 3.10.x version... Current installed version: 3.10.20 Latest available version: 3.10.20 Python 3.10 is already up to date.
If a newer release exists but you choose not to continue, the helper cancels before downloading or compiling:
Continue with update? (y/n) n Update cancelled.
After a successful update, verify both the prefix binary and the convenience symlink if you created one earlier:
/usr/local/python3.10/bin/python3.10 --version
python3.10 --version
Python 3.10.20 Python 3.10.20
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 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)
Use Pip with Deadsnakes or Source-Built Python 3.10
If you installed Python 3.10 from the Deadsnakes PPA on Ubuntu 26.04 LTS or 24.04 LTS, keep pip inside a Python 3.10 virtual environment. Creating the environment bootstraps pip for that project without writing into system site-packages:
python3.10 -m venv ~/venvs/py310
source ~/venvs/py310/bin/activate
python -m pip --version
For source builds configured with --with-ensurepip=install, pip is available from the custom prefix after installation. You can still create a project virtual environment with the same commands above to keep third-party packages isolated.
Ubuntu 22.04 LTS disables
ensurepipfor the default system Python 3.10 and prints a Debian/Ubuntu policy message instead. Use the APT method above on 22.04, then run pip through project virtual environments.
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). Python 3.10 from the Deadsnakes PPA uses a separate interpreter path, 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.
Use Python 3.10 Without Changing Ubuntu Defaults
Run Python 3.10 explicitly instead of changing global interpreter defaults. This keeps Ubuntu package tools, desktop utilities, and automation tied to the interpreter that the release owns.
Use these command patterns after installation:
- Run the interpreter directly:
python3.10 --version - Create project environments:
python3.10 -m venv ~/venvs/py310 - Install packages for that project: activate the environment, then use
python -m piporpipfrom inside the environment
For one-off commands, call the versioned binary directly:
python3.10 script.py
python3.10 -m pip --version
If a legacy script starts with #!/usr/bin/env python, prefer updating that project to use python3.10 or a virtual environment shebang. Avoid pointing /usr/bin/python3 or /usr/bin/python at Python 3.10 system-wide just to satisfy one project.
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 26.04 LTS and 24.04 LTS, add the Deadsnakes PPA first:
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install python3.10
Use the package name python3.10 without a space. A command like sudo apt install python 3.10 asks APT for two separate packages and does not install the Python 3.10 interpreter.
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.15
Version table:
3.10.12-1~22.04.15 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 python3.10-venv is missing or pinned to an older Jammy package, confirm that jammy-updates and jammy-security are enabled for the universe component, then refresh APT again.
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 --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 systems where /tmp is mounted as a small tmpfs, source builds can exhaust 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.20
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.20
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.10 -m venv myproject_env
source myproject_env/bin/activate
pip install package-name
Avoid --break-system-packages on maintained systems. If you are working in a disposable container or temporary lab system, rebuild the environment after testing instead of carrying a modified system Python into production.
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 and package ownership:
readlink -f /usr/bin/python3
dpkg -S /usr/bin/python3
The expected target differs by Ubuntu release:
Ubuntu 22.04 LTS:
/usr/bin/python3.10
Ubuntu 24.04 LTS:
/usr/bin/python3.12
Ubuntu 26.04 LTS:
/usr/bin/python3.14
If the symlink points to the wrong interpreter and APT still runs, let the package manager restore the shipped files:
sudo apt install --reinstall python3-minimal
If APT is too broken to run because the symlink already points at the wrong interpreter, restore the release-owned target as a repair step only, then reinstall python3-minimal. Use /usr/bin/python3.14 on Ubuntu 26.04 LTS, /usr/bin/python3.12 on Ubuntu 24.04 LTS, or /usr/bin/python3.10 on Ubuntu 22.04 LTS.
# Example for Ubuntu 24.04 LTS when apt is broken
sudo ln -sf /usr/bin/python3.12 /usr/bin/python3
sudo apt install --reinstall python3-minimal
After the repair, keep invoking Python 3.10 explicitly with python3.10 rather than modifying the python3 symlink again.
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 26.04 LTS or 24.04 LTS with the Deadsnakes PPA, install python3.10-venv and create a virtual environment so pip is bootstrapped inside the project. Source-compiled builds configured with --with-ensurepip=install can use ensurepip from their custom prefix.
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 through the source that installed it. Use APT for Ubuntu repository and Deadsnakes PPA builds, and use the source-build helper for manual prefixes.
Update Python 3.10 Packages on Ubuntu
On Ubuntu 22.04 LTS, update Python 3.10 and system-Python module packages from the Ubuntu repositories:
sudo apt update
sudo apt install --only-upgrade python3.10 python3.10-venv python3.10-dev python3-distutils python3-lib2to3 python3-gdbm python3-tk
On Ubuntu 26.04 LTS or 24.04 LTS with the Deadsnakes PPA, update the version-specific Python 3.10 packages from the PPA:
sudo apt update
sudo apt install --only-upgrade python3.10 python3.10-venv python3.10-dev python3.10-distutils python3.10-lib2to3 python3.10-gdbm python3.10-tk
Run the command that matches the source you used. If you did not install an optional package, omit it from the upgrade command instead of mixing Jammy system-Python package names with Deadsnakes package names.
Remove Python 3.10 Packages on Ubuntu
If a project no longer needs Python 3.10, remove only copies installed from the Deadsnakes PPA or manual source builds.
Do not purge
python3.10on Ubuntu 22.04 LTS or derivatives where it is the default system interpreter. Removing it can break APT, cloud-init, and desktop utilities. The package-removal commands in this section are for Ubuntu 26.04 LTS or 24.04 LTS systems where Python 3.10 was added as a secondary interpreter.
sudo apt remove --purge python3.10 python3.10-venv python3.10-dev python3.10-distutils python3.10-lib2to3 python3.10-gdbm python3.10-tk python3.10-dbg
Verify the package is no longer installed before cleaning up dependencies:
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' python3.10 python3.10-venv python3.10-dev python3.10-distutils python3.10-lib2to3 python3.10-gdbm python3.10-tk python3.10-dbg 2>/dev/null | grep '^ii' || echo "Python 3.10 packages are not installed"
Preview dependency cleanup, then run it only if the package list contains no unrelated tools you still need:
sudo apt autoremove --purge --dry-run
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 or trust paths. On current Ubuntu releases, add-apt-repository creates a release-named .sources file such as deadsnakes-ubuntu-ppa-noble.sources or deadsnakes-ubuntu-ppa-resolute.sources, and the remove command should delete it. The trust-path check catches any helper-created key files left behind on older or previously modified systems.
find /etc/apt/sources.list.d /etc/apt/trusted.gpg.d /etc/apt/keyrings /usr/share/keyrings -maxdepth 1 -iname '*deadsnakes*' -print 2>/dev/null | grep . || echo "No Deadsnakes source or trust files found"
No Deadsnakes source or trust files found
If the find command prints no paths, the PPA source and matching trust files are gone. Run one final source check to confirm the PPA no longer offers a live candidate:
apt-cache policy python3.10
For source builds, delete the installation directory and ld.so entry. When you compiled with the article’s prefix (/usr/local/python3.10), 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
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 Version | Availability on Ubuntu | Choose It When | Trade-offs |
|---|---|---|---|
| Install Python 3.8 on Ubuntu | Legacy PPA or source-build paths only | Compatibility testing for old applications that cannot move yet | Upstream security fixes ended October 2024; avoid for new projects |
| Python 3.10 | Ubuntu 22.04 LTS default; Deadsnakes PPA for Ubuntu 26.04 LTS and 24.04 LTS; source build when you need a custom prefix | Production fleets pinned to 3.10 APIs, older wheels, or vendor validation matrices | Upstream branch is security-only until October 2026; newer Ubuntu releases need an added interpreter |
| Install Python 3.11 on Ubuntu | Deadsnakes PPA or source build | Workloads that want newer runtime features while staying behind the newest branch | Not Ubuntu’s default interpreter on current LTS releases |
| Install Python 3.12 on Ubuntu | Ubuntu 24.04 LTS default; Deadsnakes PPA for older supported LTS releases where published | Default-runtime work on Ubuntu 24.04 LTS or projects moving beyond 3.10 | Some older packages and scripts still assume Python 3.10 behavior |
| Install Python 3.13 on Ubuntu | Deadsnakes PPA or source build where published | Testing newer typing, startup, and runtime behavior before full migration | Third-party wheels and vendor support may lag newer branches |
| Install Python 3.14 on Ubuntu | Ubuntu 26.04 LTS default; alternate installs on older releases use PPA or source-build paths where published | Default-runtime work on Ubuntu 26.04 LTS or early testing of the newest branch | Newest branch behavior can expose compatibility issues in older projects |
When to Stay on Python 3.10 on Ubuntu
Stick with Python 3.10 when you prioritize compatibility with Ubuntu 22.04 LTS defaults, vendor tools that certify against 3.10, or automation that already consumes 3.10 wheel builds. 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.
Conclusion
Python 3.10 can run alongside Ubuntu’s release-owned interpreter on 26.04 LTS, 24.04 LTS, or 22.04 LTS without changing /usr/bin/python3. Use python3.10 explicitly, keep project dependencies in virtual environments, and update through APT or the source-build helper that matches your installation method.


brilliant thanks! needed tkinter in old 3.10