Installing Latest Python on Debian/Ubuntu using Source

Installing Latest Python on Debian/Ubuntu using Source

Debian and Ubuntu install a Python for you, but it can be older than the latest stable release on Python.org. Building Python from its source code lets you install a newer version beside it, without replacing the one your system tools use.

Below, I’ll install the build tools and compile Python 3.14.8 into a folder you own.

What is a Python source install?

A Python source install compiles CPython from its source archive and places the resulting interpreter at a path you choose.

Python from source can sit beside the Python that Debian or Ubuntu installs through APT. You choose the upstream executable by its versioned name, and system tools keep their distribution-managed command.

Python.org lists Python 3.14.8 as the latest stable source release on October 3, 2026, while the 3.15 branch is still a prerelease. The distribution package can be older because each operating-system release chooses its own supported Python version.

InterpreterWho maintains itTypical path
Distribution PythonDebian or Ubuntu through APT/usr/bin/python3
Source-built Python 3.14You, outside APT’s package database$HOME/.local/bin/python3.14

Check the installed package list before building if you are unsure which interpreter APT owns. Our guide to listing installed packages with apt shows how to inspect that inventory.

A terminal can show one possible missing-interpreter state. If you only need the version supplied by Debian or Ubuntu, install that distribution package instead of compiling another copy.

Python3 Not Installed
Python3 Not Installed

The screenshot shows Bash failing to open /usr/bin/python3, but another system can print a different error or use another path. Keep the distribution interpreter in place, and add a versioned source build only when its release is what you need.

Do not remove the distribution interpreter to make room for a source build. If you need to understand the difference between apt remove and purge before changing system packages, see our apt removal guide.

Prerequisites for building CPython

Building CPython needs a C compiler and development headers for the standard-library modules you plan to use, with Debian and Ubuntu package guidance in the Python Developer’s Guide.

Install development headers before configure, because configure decides which optional modules the build can include. The packages below cover the modules checked during verification.

sudo apt update
sudo apt install build-essential curl pkg-config libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev libssl-dev libzstd-dev uuid-dev zlib1g-dev
Build componentPurpose
build-essentialCompiler and make tools
Development packages ending in -devHeaders for optional standard-library modules
pkg-configLocates installed library metadata during configure

Add tk-dev before configure only when you need the tkinter GUI module.

Install Python 3.14.8 from source

Use the stable source archive from Python.org, then set a user-owned prefix so the build stays out of directories managed by APT. The versioned install target keeps the system’s unversioned python3 command separate.

Step 1: Download and unpack the Python source

The source release page lists the tarball for Python 3.14.8. Extracting it with tar -xf creates a Python-3.14.8 directory, which is where you run configure and make.

curl -fLO https://www.python.org/ftp/python/3.14.8/Python-3.14.8.tar.xz
tar -xf Python-3.14.8.tar.xz
cd Python-3.14.8

The tar command guide explains archive extraction options if you need to inspect the source files before building.

Step 2: Configure a user-owned install prefix

Configure checks for compilers and development libraries, then writes the Makefile that controls the build. The prefix below installs the versioned interpreter under your home directory rather than /usr.

./configure --prefix="$HOME/.local"

Skip –enable-optimizations unless you need to measure profile-guided performance, which Python documents adds build time.

Step 3: Compile the configured source

Run make from the source directory after configure finishes. The -j2 option lets two build jobs run at once, which is a conservative setting for a two-core machine.

make -j2

Read the module summary after compilation. If an optional module is missing, install its development package and configure the source again so the header is detected.

Step 4: Install the versioned interpreter

Python’s Unix documentation recommends make altinstall because make install can overwrite or masquerade as the unversioned python3 executable.

make altinstall

The interpreter is installed as $HOME/.local/bin/python3.14, while APT continues to manage /usr/bin/python3. A symbolic link that redirects the system command can change which executable scripts resolve, as explained in our symbolic-link guide.

Step 5: Create a project environment with Python 3.14

A virtual environment gives one project its own package directory while leaving the interpreter install separate, and the full versioned path creates it with Python 3.14 rather than whichever python3 appears first in PATH.

mkdir -p ~/python-project
cd ~/python-project
~/.local/bin/python3.14 -m venv .venv
.venv/bin/python --version

Verify Python 3.14.8 and its modules

Compare the distribution executable with the new interpreter and its project environment. The import check catches missing development headers before you start installing packages into a build that lacks SSL or database support.

/usr/bin/python3 --version && "$HOME/.local/bin/python3.14" --version && "$HOME/python-project/.venv/bin/python" --version && "$HOME/.local/bin/python3.14" -c 'import ssl, sqlite3, bz2, lzma, zlib; print("ssl, sqlite3, bz2, lzma, and zlib loaded")'

I kept the distribution interpreter and the source build on different paths, then created the project environment from the versioned executable. The terminal output below shows Python 3.12.3 alongside Python 3.14.8 and confirms that the project environment uses 3.14.8.

Terminal output showing Python 3.12.3, Python 3.14.8, a Python 3.14.8 virtual environment, and successful standard-library imports
The distribution interpreter stays at Python 3.12.3 while the source build and project environment use Python 3.14.8.

The import command loaded ssl, sqlite3, bz2, lzma, and zlib in this build. Your distribution version can differ, while the source-built executable should report Python 3.14.8.

After activating the project environment, install packages through its Python executable, then use Python to run Linux commands and capture their output when you start automating system tasks.

Fix a build with missing optional modules

Configure detects development headers before compilation, so an interpreter can build successfully while optional modules remain absent. Match the missing module to its development package, install that package, then configure and compile the source again.

Missing moduleDevelopment package
ssl or hashliblibssl-dev
sqlite3libsqlite3-dev
bz2libbz2-dev
lzmaliblzma-dev
readlinelibreadline-dev
tkintertk-dev

Configure must detect a development header before it can include the matching module. Install the package, run configure and make from the source directory, then use the import probe below.

"$HOME/.local/bin/python3.14" -c 'import ssl, sqlite3, bz2, lzma, zlib'

Keep the distribution interpreter under APT

A separate prefix and a versioned executable let you choose the newer CPython for a project without changing the interpreter that system tools expect. Keep using the explicit path when you create each environment.

~/.local/bin/python3.14 -m venv .venv

That path choice is the boundary that keeps APT and your source build from claiming the same interpreter name.

Python source-install questions

Python.org controls the upstream release, while APT controls the interpreter installed from your distribution repositories.

What is the latest stable Python release?

Python.org lists Python 3.14.8 as the latest stable source release on October 3, 2026. Check the source releases page when choosing a newer tarball.

Does make altinstall replace the system python3?

No. make altinstall installs the versioned executable, such as python3.14. Use a user-owned prefix such as $HOME/.local and keep the distribution’s /usr/bin/python3 under APT.

Will APT update Python that I built under $HOME/.local?

No. APT updates the interpreter it installed from the distribution repository. A source build under $HOME/.local is outside that package database, so download and build a newer CPython release when you want to replace it.