How to Install Python 3.8 on Debian Linux 12, 11 or 10

In the ever-evolving landscape of programming languages, Python 3.8 marked a pivotal juncture, bringing forth a slew of enhancements and features. For those harnessing the power of Debian systems, specifically Debian 12 Bookworm, Debian 11 Bullseye, or Debian 10 Buster, integrating Python 3.8 can be a strategic move, ensuring a harmonious blend of stability and advanced functionalities.

Some Historical Key Features of Python 3.8:

  • Assignment Expressions: The advent of the walrus operator := ushered in the capability to assign values within expressions, streamlining coding practices.
  • Positional-only Parameters: With the introduction of the / syntax, Python 3.8 made it explicit that specific function parameters are strictly positional, enhancing clarity.
  • Revamped F-strings: The = specifier in f-strings facilitated self-documenting expressions, simplifying debugging.

Notable Historical Performance Enhancements:

  • Shared Memory in Multiprocessing: This feature paved the way for efficient data interchange between processes, optimizing computational tasks.
  • Accelerated import(): The module import mechanism underwent optimization, resulting in swifter performance and reduced load times.

Given Python 3.8’s rich feature set, it remains a preferred choice for many developers. Now, let’s move into downloading, compiling, and installing this version of Python on your Debian system.

Install Python 3.8 on Debian 12, 11, or 10 via the source

This section will guide you through installing Python 3.8 on Debian 12, 11, or 10 by compiling the source code. This method gives you the most control over the installation. It ensures you get the latest Python release, as by now, Debian 11 Bullseye and Debian 12 Bookworm onwards do not even feature Python 3.8 in their default archives.

Step 1: Update Debian Packages Before Python 3.8 Installation

It is prudent to ensure your Debian system is up-to-date before you proceed with the installation. This step ensures that the existing packages are compatible with the ones we will install.

sudo apt update && sudo apt upgrade

Step 2: Install Development Packages for Python 3.8 Installation

In this step, we will install a set of packages essential for compiling Python from the source. These include development libraries and other utilities used during the compilation process.

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev -y

Step 3: Download Python 3.8 Source Code on Debian

Now, download the Python 3.8 source code from the official Python website. Make sure you have the latest version by checking the official downloads page. As of this writing, the latest security release is Python 3.8.17.


Step 4: Extract Python Archive and Move to Appropriate Directory

After downloading the source code, we need to extract it. Here, the tar command is used for extraction.

tar -xf Python-3.8.12.tar.xz

For organizational purposes, it’s a good practice to move the extracted files to a standard location within /usr/local/. In this guide, we will move them to /usr/local/share.

mv Python-3.8.17 /usr/local/share/python3.8

Step 5: Configure, Compile, and Install Python 3.8 on Debian

Now, navigate to the directory containing the Python source code. We will run the ./configure script with certain flags for optimization and enabling shared libraries.

cd /usr/local/share/python3.8
./configure --enable-optimizations --enable-shared

The --enable-optimizations flag tells the script to perform several checks to ensure all dependencies are present and optimizes the Python binary by running multiple tests. The --enable-shared flag builds shared libraries, which are essential for certain types of applications.

You may also consider using the --with-ensurepip=install flag to install the pip package manager alongside Python.

Now, it’s time to compile the source code using the make command.


For faster compilation, especially on systems with multiple CPU cores, you can use the -j flag followed by the number of CPU cores you want to utilize. For example, if your system has 6 CPU cores, you could use 5 of them:

make -j 5

Once the compilation is complete, install the Python binaries. It’s recommended to use the make altinstall command to avoid overwriting the default Python binary in the system.

sudo make altinstall

After the installation, configure the dynamic linker run-time bindings. This is an essential step and should not be skipped; neglecting to do so may lead to issues.

sudo ldconfig /usr/local/share/python3.8

Step 6: Verify Python 3.8 Installation on Debian

Finally, let’s verify the installation by checking the Python version. This step is crucial to confirm that Python 3.8 was successfully installed and is ready for use.

python3.8 --version

You should see output similar to the following:

Python 3.8.17

Create a Test Virtual Environment on Debian 12, 11 or 10

In this section, we’ll set up a virtual environment using Python 3.8. Virtual environments are a best practice in Python development as they isolate project-specific dependencies and avoid potential conflicts with other Python projects or system libraries.

Step 1: Create a Test Project Directory

First, we must create a directory that will hold our Python project. This is where we will set up our virtual environment. Execute the following commands to create a directory named test_app and navigate into it:

mkdir ~/test_app
cd ~/test_app

Step 2: Create a Virtual Environment

Now that we have the project directory, let’s create a Python virtual environment. We will use Python’s venv module, which comes pre-installed with Python 3.3 and later versions. This module helps in creating lightweight virtual environments.

Run the following command to create a virtual environment named test_app_venv:

python3.8 -m venv test_app_venv

Here, -m venv indicates that we are using the venv module. The test_app_venv is the name of the virtual environment, and you can name it anything that makes sense for your project.

Step 3: Activating the Python Virtual Environment on Debian

With the virtual environment created, the next step is to activate it. Activating the virtual environment will isolate it, ensuring that any Python commands you run or any Python packages you install will be confined to this environment.

Activate the Python environment:

source test_app_venv/bin/activate

You’ll know you’re in the virtual environment because its name will now appear on the left of the terminal prompt. For example:

(test_app_venv) user@debian:~/test_app$

This indicates that you are currently operating inside the test_app_venv virtual environment. Any Python packages you install now will only be available within this environment.

Step 4: Deactivating the Virtual Environment on Debian

Once you are done working in the virtual environment, you can deactivate it to return to the system-wide Python environment.

This is done simply by typing:


Once deactivated, the prefix in the terminal prompt will disappear, indicating that you are no longer in the virtual environment.

Install Pip on Debian 12, 11, or 10

This section will focus on installing Python’s package manager, Pip, alongside Python 3.8. Pip is an essential tool for Python developers as it facilitates installing and managing Python libraries and packages.

Step 1: Verifying the Installation of Pip on Debian

Python 3.8 usually includes Pip. Check its presence using the following:

python3.8 -m pip --version

If this command shows Pip’s version, it’s installed. If not, proceed to the next steps for manual installation.

Step 2: Download the Pip Installation Script on Debian

To install Pip for Python 3.8, we will download a Python script to manage the installation process. This script, named, can be downloaded using the wget command.

Execute the following command to download the Pip installation script:


This command retrieves the script from the official repository and saves it in the current directory.

Step 3: Install Pip for Python 3.8 on Debian 12, 11, or 10

With the script downloaded, it’s time to install Pip. Execute the following command to run the script with Python 3.8:


This command tells Python 3.8 to execute the script, installing Pip.

Upgrade Pip to the Latest Version

Always ensure you’re using the most recent version of Pip. Update Pip with:

python3.8 -m pip install --upgrade pip

This uses Python 3.8’s instance of Pip to upgrade to the latest version.

Conclusion and Final Thoughts

This guide covers the installation of Python 3.8 on Debian 12, 11, or 10. First, update your system and install Python 3.8 from the official repositories. Next, set up a virtual environment to separate your Python projects. This is a standard approach in Python development. Lastly, install and upgrade Pip, the Python package manager, which is vital for handling Python libraries.

Always keep Python and tools like Pip up to date. Doing so gives you the newest features and fixes security issues. Regularly updating your tools boosts the efficiency and security of your Python development setup.

Leave a Comment

Your Mastodon Instance
Share to...