How to Install Python 3.8 on Ubuntu

Python 3.8 reached end-of-life in October 2024 and no longer receives upstream security updates, yet some legacy applications still require it. Common scenarios include vendor tools that ship only Python 3.8 wheels, internal automation that has not been validated on newer Python releases, and self-hosted apps pinned to Python 3.8 by upstream requirements. Ubuntu 22.04 ships Python 3.10, Ubuntu 24.04 ships 3.12, and Ubuntu 26.04 ships 3.13, so installing Python 3.8 on Ubuntu requires the Deadsnakes PPA on 22.04/24.04 or a source build on any supported LTS release.

This guide walks through adding Python 3.8 via the community-maintained Deadsnakes PPA (Personal Package Archive) on Ubuntu 22.04/24.04 or compiling from source on all supported LTS releases, bootstrapping PIP without breaking Ubuntu’s externally managed system Python, and managing multiple interpreters safely. By the end, you will have Python 3.8 installed alongside Ubuntu’s default interpreter, verified with working SSL support, and isolated in virtual environments to prevent system conflicts. Treat every Python 3.8 deployment as temporary and plan migrations to Python 3.10 or newer for continuing security updates.

Choose Your Python Version for Ubuntu

Compare Supported Python Releases

Each Python version on Ubuntu targets different support lifecycles and compatibility needs. Python 3.8 no longer receives upstream security updates, while 3.10, 3.11, 3.12, 3.13, and 3.14 maintain active security support on their own timelines.

Review the Release Comparison

Python VersionPrimary FocusBest ForTrade-offs
Python 3.8Legacy application support and EOL compatibilityLegacy applications pinned to Python 3.8-only dependencies, vendor tools shipping 3.8 wheels, short-term migration windowsEnd-of-life October 2024, no upstream security patches, ecosystem support declining rapidly, requires Deadsnakes PPA or source compilation
Python 3.10Stable production runtime with security supportProduction applications needing structural pattern matching, better error messages, multiple context managers, security-conscious deploymentsEnd-of-life October 2026, some newer libraries dropping support, Ubuntu 22.04 default (24.04 ships 3.12; 26.04 ships 3.13)
Python 3.11Performance improvements and error handlingApplications benefiting from runtime optimizations, better exception groups, TOML support, fine-grained error locationsEnd-of-life October 2027, not Ubuntu default on any LTS, requires Deadsnakes PPA on 22.04/24.04
Python 3.12Modern Python with comprehension inlining and f-string improvementsNew projects, Ubuntu 24.04 LTS default, development workstations, applications using PEP 701 f-strings, improved debuggerEnd-of-life October 2028, some older libraries not yet compatible, Ubuntu 22.04 users need the Deadsnakes PPA
Python 3.13Newest Ubuntu LTS default with new language features and typing refinementsUbuntu 26.04 LTS default, development that needs recent features, forward-looking testing with support through October 2029Some third-party wheels lag early releases, Ubuntu 22.04/24.04 require the Deadsnakes PPA
Python 3.14Latest interpreter features and optional free-threaded buildsForward-looking development that needs the newest features, free-threaded testing, support through October 2030Not the default on any Ubuntu LTS, requires the Deadsnakes PPA on 22.04/24.04 or source builds on 26.04, some wheels lag early releases

Choose a Default or Add-On Interpreter

Ubuntu 22.04 ships Python 3.10, Ubuntu 24.04 ships 3.12, and Ubuntu 26.04 ships 3.13, so most new projects can stay on the default interpreter for their release. Choose Python 3.11 when you need its error handling improvements and runtime optimizations, but treat any non-default interpreter as an add-on runtime. The default versions are available from Ubuntu repositories, while Python 3.8 and other non-default releases require the Deadsnakes PPA on 22.04/24.04 or source builds on all supported LTS releases.

Decide When to Keep Python 3.8

Only install Python 3.8 when a legacy application cannot immediately move forward. The interpreter no longer receives upstream security patches, and modern frameworks such as Django 5.0 or NumPy 2.0 no longer support it.

Treat every Python 3.8 deployment as a transitional solution while you plan migrations to Python 3.10 or newer for continuing security updates and ecosystem compatibility.

Choose Your Python 3.8 Installation Method

Select the installation method that matches your deployment requirements. Most users should choose the Deadsnakes PPA for simplicity, while source compilation suits air-gapped environments or workloads requiring custom optimization flags.

Installation OptionBest ForTrade-offs
Deadsnakes PPAUbuntu 22.04 and 24.04 systems that need packaged Python 3.8 builds integrated with aptCommunity-maintained packages with no guaranteed security updates; not available on Ubuntu 26.04; still must avoid replacing Ubuntu’s default python3
Compile from SourceStrict compliance or air-gapped environments that need custom patches, --enable-optimizations, or alternate prefixes such as /opt/python3.8Takes longer to build, you manage updates yourself, requires build dependencies on all supported LTS releases

Whichever method you pick, never replace the default /usr/bin/python3 interpreter. Ubuntu’s package manager, desktop tools, and cloud-init all depend on the version that ships with the distribution.

These steps cover Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS. Use the Deadsnakes PPA only on 22.04 or 24.04 because it does not publish packages for 26.04, while source compilation works on all supported LTS releases. Follow the version-specific notes where commands differ.

Understand Support and Compatibility Limits

  • Ubuntu archives no longer ship python3.8: visiting https://packages.ubuntu.com/jammy/python3.8, https://packages.ubuntu.com/noble/python3.8, or https://packages.ubuntu.com/resolute/python3.8 returns “No such package.” Expect apt install python3.8 to fail on Ubuntu 22.04, 24.04, and 26.04 unless you add a third-party source such as Deadsnakes or build from source.
  • Deadsnakes PPA carries a “no guaranteed updates” disclaimer on Launchpad. Production users must monitor CVEs themselves and be ready to recompile or sandbox workloads until patched packages arrive.
  • Ecosystem support has already moved on: Django 5.0 only supports Python 3.10-3.12 (Django 5.0 Python support), and NumPy 2.0 supports Python 3.9-3.12 (NumPy 2.0 release notes). Expect modern frameworks to reject python3.8 builds outright on Ubuntu 24.04 and 26.04, so gate new application updates carefully.

Python 3.8 reached upstream end-of-life on 7 October 2024, per the official lifecycle tracker. Install Python 3.8 only when a legacy application demands it, isolate that workload (venv, containers, snaps), and plan a migration to a supported interpreter. Ubuntu 22.04 ships Python 3.10, Ubuntu 24.04 ships 3.12, and Ubuntu 26.04 ships 3.13.

Python 3.8 Pre-Installation Steps

Update System Before Proceeding

Before installing Python 3.8, update your system’s package lists with APT (Ubuntu’s package manager) to ensure all dependencies resolve correctly and you receive the latest security patches. This step is particularly important when adding third-party repositories like Deadsnakes or compiling software from source, as build tools and libraries frequently receive compatibility updates.

Open a terminal and run:

sudo apt update

After refreshing package lists, upgrade any installed packages to their latest versions. This step prevents conflicts between outdated system libraries and newly compiled software, particularly when building Python from source with --enable-optimizations.

Run the upgrade command:

sudo apt upgrade

Once your system is updated, select an installation method based on your deployment requirements. Most users should choose the Deadsnakes PPA for simplicity, while custom compilation suits air-gapped environments or workloads requiring specific optimization flags.

Install Python 3.8 from the Deadsnakes PPA

Add Deadsnakes PPA Repository

If add-apt-repository is missing (minimal, WSL, or container installs), install it first:

sudo apt install software-properties-common

The Deadsnakes PPA publishes packages for Ubuntu 22.04 and 24.04 only, so Ubuntu 26.04 users should skip this section and use the source build method. This guide targets Ubuntu; Ubuntu-based distributions such as Linux Mint 22 may block this PPA by default.

Deadsnakes is a community-maintained Launchpad PPA that provides non-default Python releases for Ubuntu, including Python 3.8 on supported LTS versions. Add the “deadsnakes” team PPA with the command below:

The Launchpad package list confirms that Python 3.8.20 builds exist for Ubuntu 22.04 (Jammy) and 24.04 (Noble), so both LTS releases can install python3.8 directly from this PPA without manual compilation.

Launchpad also reiterates the Deadsnakes disclaimer: there is no guarantee of timely security fixes, so production teams must monitor CVEs and be ready to recompile or sandbox workloads if a vulnerability appears before patched packages land.

sudo add-apt-repository ppa:deadsnakes/ppa -y

The -y flag auto-accepts the repository prompt, which is useful for scripted installs but skips the interactive confirmation.

Configure APT Pinning (Recommended)

Deadsnakes includes multiple Python versions, so pin the PPA to prefer only Python 3.8 packages. The Origin value for this PPA is LP-PPA-deadsnakes:

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

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

This keeps other PPA packages at lower priority while allowing Python 3.8 packages to install from Deadsnakes.

Update Package List After Python 3.8 Import

After importing the PPA, you must update your package list to ensure your system recognizes the newly added repository. To do this, run the following command in your terminal:

sudo apt update

On Ubuntu 26.04, apt update reports that the resolute Release file is missing, which means the PPA does not support 26.04. If you see the message below, skip the PPA method and use the source build steps instead:

E: The repository 'https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu resolute Release' does not have a Release file.

Verify Deadsnakes PPA is Active

Before installing Python 3.8, verify that the Deadsnakes PPA is active and providing the package. This confirms the repository was added successfully:

apt-cache policy python3.8

Expected output on Ubuntu 22.04 (jammy):

python3.8:
  Installed: (none)
  Candidate: 3.8.20-1+jammy1
  Version table:
     3.8.20-1+jammy1 700
        100 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 Packages

Expected output on Ubuntu 24.04 (noble):

python3.8:
  Installed: (none)
  Candidate: 3.8.20-1+noble1
  Version table:
     3.8.20-1+noble1 700
        100 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble/main amd64 Packages

The output confirms Python 3.8.20 is available from the PPA. If you skipped pinning, the priority will show 500 instead of 700. The version number may differ based on the latest release, and the distribution name (jammy or noble) matches your Ubuntu version.

Install Python 3.8 via APT Command

With the PPA successfully imported and your package list updated, you’re ready to install Python 3.8 on Ubuntu 22.04 or 24.04. To do so, run the following command:

sudo apt install python3.8

Verify Python 3.8 Installation

After installation completes, verify Python 3.8 installed correctly by checking the version string:

python3.8 --version

This command displays the installed Python 3.8 version, confirming the installation succeeded:

Python 3.8.20

Next, verify that the SSL module compiled correctly (critical for OpenSSL 3 compatibility on Ubuntu 22.04 and newer):

python3.8 -c "import ssl, sqlite3, bz2; print('Core modules OK')"

Expected output confirming all core modules loaded successfully:

Core modules OK

If the ssl import fails, see the “OpenSSL Module Build Failures” section in Troubleshooting below for diagnosis and resolution steps.

Install Additional Python Packages on Ubuntu (Optional)

If desired, you can also install the following extras:

PackageWhy Install It
python3.8-dbgProvides debugging symbols so you can trace crashes or attach gdb to Python processes
python3.8-devInstalls headers for compiling native extensions such as uvloop or psycopg2
python3.8-venvEnables the built-in venv module so you can isolate dependencies per project
python3.8-distutilsProvides the legacy Distutils packaging tools still used by some build scripts
python3.8-lib2to3Installs the modernization tool used to port legacy Python 2 code
python3.8-gdbmAdds GNU dbm bindings so your apps can use dbm.gnu databases
python3.8-tkShips Tk bindings (Tkinter) for GUI applications

Installing python3.8-venv pulls in python3.8-distutils and python3.8-lib2to3 automatically, so you may already have those packages once venv is installed.

Install optional modules individually as needed:

sudo apt install python3.8-dbg
sudo apt install python3.8-dev
sudo apt install python3.8-venv
sudo apt install python3.8-distutils
sudo apt install python3.8-lib2to3
sudo apt install python3.8-gdbm
sudo apt install python3.8-tk

Only install legacy components like python3.8-distutils or python3.8-lib2to3 when a project explicitly requires them; modern packaging tools favor pip, setuptools, and pyproject.toml-based builds.

Install whichever modules you need in a single apt command to save time:

sudo apt install python3.8-venv python3.8-dev python3.8-tk

Update Python 3.8 Packages from the PPA

When updates are available, upgrade only the Python 3.8 packages you installed to avoid pulling in unrelated PPA packages:

sudo apt install --only-upgrade python3.8 python3.8-venv python3.8-dev

Add or remove python3.8-* packages in the command based on what you installed.

Compile Python 3.8 from Source on Ubuntu

Download Python 3.8 Source Code

Visit the official Python download page and copy the download link for the latest Python 3.8.x release. If curl is missing, install it first:

sudo apt install curl

Now download the Python 3.8 source archive:

curl -fsSLO https://www.python.org/ftp/python/3.8.20/Python-3.8.20.tar.xz

The -f flag fails on HTTP errors, -sS keeps output quiet while still showing errors, -L follows redirects, and -O saves the file with its original name.

Download links on python.org change regularly, so copy the latest Python 3.8.x URL before running curl and update the version fields in the following commands to match.

After downloading the Python archive, extract it using tar:

tar -xf Python-3.8.20.tar.xz

Install Build Dependencies

Before compiling Python from source, install the build dependencies. The build-essential package provides GCC and core compilation tools, while the development libraries supply headers for SSL, compression, and database support:

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

These package names exist on Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS because they pull from the standard distribution development meta-packages. For complex projects that require additional build systems beyond make, you may also want to install CMake, though Python’s build process does not require it.

Python 3.8.16+ is required on Ubuntu 22.04, 24.04, and 26.04 because these releases only ship OpenSSL 3 (libssl3). Earlier 3.8.x builds expect OpenSSL 1.1.1 and will fail to build the ssl module. Always download the latest 3.8.x tarball before compiling.

Configure the Python Build Environment

Navigate to the extracted source directory:

cd Python-3.8.20/

Now, run the ./configure command with the --enable-optimizations and --enable-shared options:

./configure --enable-optimizations --enable-shared

The script will perform several checks to ensure that all necessary dependencies are present on your system. Running ./configure with --enable-optimizations will optimize the Python binary by running multiple tests. This can make the build process slower but will result in a faster and more efficient Python installation.

Compile Python 3.8

After configuring the build environment, compile Python using the make command. To significantly speed up compilation, use the -j flag to enable parallel builds across multiple CPU cores:

make -j $(nproc)

The $(nproc) command automatically detects your available CPU cores and runs that many parallel jobs, significantly speeding up compilation.

Install Python Binaries

After finishing the building process, install the Python binaries by running the following command: sudo make altinstall. Using the make altinstall command is recommended to avoid overwriting the default Python 3 binary system.

sudo make altinstall

After installation, update the dynamic linker cache so the system can locate the Python 3.8 shared library (libpython3.8.so) when running Python or importing extension modules. If you compiled with the default prefix (--prefix=/usr/local), run:

sudo ldconfig /usr/local/lib

When you compiled with a custom prefix (for example ./configure --prefix=/opt/python3.8), provide that path explicitly:

sudo ldconfig /opt/python3.8/lib

Verify Python 3.8 Installation

After configuring the dynamic linker, confirm the source-compiled Python 3.8 installation succeeded and the version matches your downloaded release:

python3.8 --version

Expected output:

Python 3.8.20

Additionally, verify critical modules like SSL compiled correctly, as missing development headers during compilation cause silent module failures. Run this test to confirm OpenSSL 3 compatibility:

python3.8 -c "import ssl; print('SSL module OK'); print(ssl.OPENSSL_VERSION)"

Expected output showing SSL module loaded with OpenSSL 3:

SSL module OK
OpenSSL 3.x.x ...

OpenSSL version strings differ by release (3.0.2 on Ubuntu 22.04, 3.0.13 on Ubuntu 24.04, and 3.5.x on Ubuntu 26.04), so focus on seeing OpenSSL 3.x listed.

Update a Source-Built Python 3.8 Installation

Source builds do not update themselves. Run the script below manually when you want to rebuild to a newer 3.8.x release, and update the VERSION value before running it.

This script uses a dedicated build directory at /opt/python3.8-build and the default prefix /usr/local. If you installed to a custom prefix, update PREFIX to match. Do not run this on a cron schedule.

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

VERSION="3.8.20"
PREFIX="/usr/local"
BUILD_DIR="/opt/python3.8-build"

if ! command -v python3.8 >/dev/null 2>&1; then
  echo "python3.8 is not installed. Build it first, then use this update script."
  exit 1
fi

sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev liblzma-dev pkg-config make

sudo mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

curl -fsSLO "https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tar.xz"
tar -xf "Python-${VERSION}.tar.xz"
cd "Python-${VERSION}"

./configure --prefix="$PREFIX" --enable-optimizations --enable-shared
make -j "$(nproc)"
sudo make altinstall
sudo ldconfig "$PREFIX/lib"

Install PIP with Python 3.8

Understand PIP Packaging on Ubuntu

The system python3-pip package only wires PIP to Ubuntu’s default interpreter (3.10 on 22.04, 3.12 on 24.04, 3.13 on 26.04), not to Python 3.8. For comprehensive coverage of PIP functionality and advanced usage, refer to the dedicated PIP on Ubuntu guide.

Ubuntu repository Python modules are built for the default interpreter, so compiled extension packages installed from apt (for example python3-psycopg2) will not load under Python 3.8 from Deadsnakes. Use python3.8 -m pip inside a virtual environment for third-party dependencies instead.

If you installed Python 3.8 from the PPA, install python3.8-venv to enable ensurepip and virtual environments:

sudo apt install python3.8-venv

If you compiled Python 3.8 from source, ensurepip is bundled by default, so you can skip this step unless you disabled it at build time.

To install PIP specifically for Python 3.8, use one of the methods below instead:

Method 1: Bootstrap PIP with ensurepip

Python includes a bundled bootstrap module named ensurepip that installs the version of PIP packaged with the interpreter. This method is the simplest and works offline. Run the following to install (or refresh) PIP for Python 3.8:

python3.8 -m ensurepip --upgrade

This method avoids fetching an external script and works in minimal, offline, or restricted environments. After using ensurepip, upgrade to the latest release with python3.8 -m pip install --upgrade pip to pick up current security fixes.

Method 2: Download and Run get-pip.py

Alternatively, manually install PIP using the official bootstrap script provided by the Python Packaging Authority (PyPA). If curl is missing, install it first:

sudo apt install curl

Now download the Python 3.8-specific script:

curl -fsSLO https://bootstrap.pypa.io/pip/3.8/get-pip.py

This uses the same curl flags described in the source download step.

This script is provided by the Python Packaging Authority (PyPA) and is used to install or upgrade PIP on your system.

Run the PIP Installation Script

After downloading the bootstrap script, execute it with Python 3.8 to install PIP specifically for this interpreter:

python3.8 get-pip.py

This will install PIP specifically for Python 3.8 on your system.

Ubuntu 24.04 and 26.04 mark the system python3 interpreter as externally managed (PEP 668), so python3 -m pip install for the system interpreter fails unless you use a virtual environment. This does not apply to Python 3.8 from the Deadsnakes PPA or source builds, but you should still use python3.8 -m venv to isolate project dependencies.

Upgrade PIP to the Latest Version

After installing PIP, upgrade it to the latest version to access recent bug fixes and features. Always specify the python3.8 interpreter explicitly to avoid accidentally upgrading Ubuntu’s system-wide PIP, which could break apt-managed packages:

python3.8 -m pip install --upgrade pip

You should see output similar to the following:

$ python3.8 -m pip install --upgrade pip
Collecting pip
  Downloading pip-25.x-py3-none-any.whl (1.8 MB)
Successfully installed pip-25.x

This output indicates that PIP has been upgraded to the latest version.

Verify the Installed PIP Version

Confirm PIP installed correctly and check which version is bound to your Python 3.8 interpreter:

python3.8 -m pip --version

This will display the current PIP version associated with your Python 3.8 installation.

Expected output:

pip 25.x from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

Manage Multiple Python Versions Safely on Ubuntu

If you need multiple versions of Python installed on your system and want to control which interpreter launches when you run python, follow these guardrails to avoid breaking core Ubuntu tools.

Do Not Replace Ubuntu’s Default Python 3 Interpreter

Ubuntu binds thousands of packages (APT, software-properties-gtk, update-manager, cloud-init, Ansible controllers, etc.) to the specific /usr/bin/python3 version that shipped with your release. Replacing that binary or symlink with Python 3.8 causes modules compiled for the distro version to disappear, and everyday commands immediately fail.

Leave /usr/bin/python3 untouched. Install additional interpreters via the Deadsnakes PPA, make altinstall, or tools like pyenv so they register as /usr/bin/python3.8 or /opt/python3.8/bin/python3.8 instead of replacing the system Python.

For example, symlinking /usr/bin/python3 to Python 3.8 immediately breaks apt update because the apt_pkg module is compiled specifically for Ubuntu’s stock interpreter.

Traceback (most recent call last):
  File "/usr/bin/apt", line 27, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

This is why every command in this guide either references python3.8 directly or installs into isolated environments. Keep that habit when scripting.

Virtual Environments Are the Safest Approach

The safest approach for Python 3.8 workloads is creating per-project environments with python3.8 -m venv instead of modifying system-wide settings. This keeps Ubuntu’s stock Python untouched while giving every project the interpreter it requires, and avoids PEP 668 PIP restrictions entirely. Refer to the Python virtual environment guide for detailed setup instructions, or isolate entire workloads inside Docker containers for larger deployments.

Troubleshooting Common Python 3.8 Installation Issues

OpenSSL Module Build Failures

When compiling Python 3.8 on Ubuntu 22.04 or newer, the build may complete successfully but the ssl module fails to load with import errors. This happens because Ubuntu 22.04+ ships OpenSSL 3.x, while Python 3.8.0 through 3.8.15 were designed for OpenSSL 1.1.1.

Test if you have this issue:

python3.8 -c "import ssl; print(ssl.OPENSSL_VERSION)"

Expected output shows the OpenSSL version string (varies by release):

OpenSSL 3.x.x ...

If this command fails with ModuleNotFoundError: No module named '_ssl', you compiled an older Python 3.8 release against OpenSSL 3. The solution is to download Python 3.8.16 or newer (preferably 3.8.20) and recompile following the source compilation steps above.

Missing Development Headers During Compilation

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.

Check for disabled modules during configuration:

./configure --enable-optimizations --enable-shared 2>&1 | grep "disabled"

Example output when modules are missing:

checking for stdlib extension module _ssl... disabled
checking for stdlib extension module _bz2... disabled

If the command prints nothing, no optional modules were disabled.

During make, you may instead see a summary of missing optional modules:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_dbm                  _tkinter              _uuid
nis

If you need those modules, install the matching development headers and rebuild. On Ubuntu, the common packages are libdb-dev for _dbm, uuid-dev for _uuid, tcl-dev and tk-dev for _tkinter, and libnsl-dev for nis.

sudo apt install libdb-dev uuid-dev tcl-dev tk-dev libnsl-dev

After installing the headers, re-run ./configure, make, and make altinstall to rebuild Python with those modules enabled.

If you see “Failed to build these modules” near the end of the compilation output, install the matching headers and rebuild using the same steps described above.

Shared Library Linking Errors

When running python3.8 after source compilation, you may encounter an error stating error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file. This happens when the dynamic linker cannot locate the Python shared library because it was installed outside standard library paths.

First, verify the library exists:

find /usr/local -name "libpython3.8.so*"

Expected output showing the shared library location:

/usr/local/lib/libpython3.8.so.1.0
/usr/local/lib/libpython3.8.so

Then update the linker cache with the correct path:

sudo ldconfig /usr/local/lib

Verify the library is now findable:

ldconfig -p | grep python3.8

Expected output showing the library path:

libpython3.8.so.1.0 (libc6,x86-64) => /usr/local/lib/libpython3.8.so.1.0

PIP Externally-Managed Environment Errors

On Ubuntu 24.04 and 26.04, the system python3 interpreter is externally managed (PEP 668). This affects python3 -m pip install for the system interpreter, not Python 3.8 from the PPA or source builds, but you should still use virtual environments to isolate Python 3.8 dependencies.

Example error output when you try to use the system interpreter with PIP:

error: externally-managed-environment

This environment is externally managed.
To install Python packages system-wide, try: apt install python3-xyz
If you want to use pip, create a virtual environment with python3 -m venv path/to/venv.
note: You can override this with --break-system-packages (not recommended).
hint: See PEP 668 for the detailed specification.

The recommended solution is creating a virtual environment for each project:

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

APT Breaking After Installing Python 3.8 PPA

If apt update or apt install fails with Python-related errors after adding the Deadsnakes PPA, ensure you did not accidentally replace Ubuntu’s system Python 3 interpreter. Check which interpreter /usr/bin/python3 points to:

readlink -f /usr/bin/python3

Expected output by release:

/usr/bin/python3.10
/usr/bin/python3.12
/usr/bin/python3.13

If it points to python3.8 instead, restore the original symlink for your release:

sudo ln -sf /usr/bin/python3.10 /usr/bin/python3  # Ubuntu 22.04
sudo ln -sf /usr/bin/python3.12 /usr/bin/python3  # Ubuntu 24.04
sudo ln -sf /usr/bin/python3.13 /usr/bin/python3  # Ubuntu 26.04

Always invoke Python 3.8 explicitly using python3.8 rather than modifying the python3 symlink.

Uninstalling Python 3.8 from Ubuntu

Remove Deadsnakes PPA Installation

To completely remove Python 3.8 installed from the Deadsnakes PPA, confirm the package is not marked essential before removing it:

apt-cache show python3.8 | grep -i '^Essential'

Expected output (no lines means it is not essential):

(no output)

Now remove all python3.8 packages:

sudo apt remove --purge python3.8*

This removes all Python 3.8 packages, including optional components like python3.8-dbg, python3.8-distutils, python3.8-lib2to3, python3.8-gdbm, and python3.8-tk if you installed them.

After removing the main packages, clean up orphaned dependencies that were automatically installed:

sudo apt autoremove

Remove the PPA repository, pinning file, and key to prevent future updates:

sudo rm -f /etc/apt/preferences.d/python3.8.pref
sudo rm -f /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-*.list
sudo rm -f /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-*.sources
sudo rm -f /etc/apt/trusted.gpg.d/deadsnakes-ubuntu-ppa.gpg /etc/apt/trusted.gpg.d/deadsnakes-ubuntu-ppa.gpg~
sudo apt update

If you did not use pinning or your release stored the key inline in the .sources file, some files may not exist and can be safely ignored.

Verify Python 3.8 is no longer available:

apt-cache policy python3.8

Expected output confirming the package is no longer available:

N: Unable to locate package python3.8

Remove Source-Compiled Installation

For source-compiled Python 3.8 installed via make altinstall, manually remove the binaries and libraries. If you used the default prefix (/usr/local), remove these files:

Warning: The following commands permanently delete the source-compiled installation. If you have custom configurations or scripts relying on this Python installation, back them up first with cp -r /usr/local/lib/python3.8 ~/python38-backup.

sudo rm -rf /usr/local/bin/python3.8*
sudo rm -rf /usr/local/bin/pip3.8*
sudo rm -rf /usr/local/lib/python3.8
sudo rm -rf /usr/local/lib/libpython3.8*
sudo rm -rf /usr/local/include/python3.8
sudo ldconfig

If you used the update script or a dedicated build directory, remove it as well:

sudo rm -rf /opt/python3.8-build

Verify the source-compiled installation is removed:

command -v python3.8 || echo "python3.8 not found"

Expected output when removal is complete:

python3.8 not found

When you compiled with a custom prefix like --prefix=/opt/python3.8, simply remove that directory:

sudo rm -rf /opt/python3.8
sudo ldconfig

Keep Python 3.8 Isolated as a Legacy Runtime

Python 3.8 is no longer the default interpreter on supported Ubuntu releases. Ubuntu 22.04 ships Python 3.10, Ubuntu 24.04 ships 3.12, and Ubuntu 26.04 ships 3.13, so installing python3.8 today always introduces an extra runtime. Treat it like legacy tooling on Windows: leave the system binaries untouched and run legacy apps inside isolated virtual environments or containers.

Create a dedicated environment for every Python 3.8 workload, keep those configurations under version control with the project, and document the migration path in your deployment notes. This approach protects Ubuntu’s system interpreter, apt tooling, and future upgrades to newer Python releases while still supporting legacy applications.

Conclusion

Python 3.8 remains accessible on Ubuntu through the Deadsnakes PPA (22.04/24.04) or source compilation (all supported LTS releases) despite reaching end-of-life in October 2024. You now have Python 3.8 installed alongside Ubuntu’s default interpreter without disrupting system tools, package management, or distribution upgrades. The Deadsnakes PPA provides apt-managed builds on 22.04/24.04, while source compilation offers control over optimization flags and custom installation prefixes. Isolate every Python 3.8 workload in virtual environments using python3.8 -m venv and prioritize migrations to Python 3.10 or newer for continuing security updates and modern framework compatibility.

Leave a Comment