How to install Python 3.8 on Debian 10

Python is one of the most widely used programming languages ​​in the world. With a simple and easy-to-learn syntax, Python is a popular choice for both beginners and experienced developers. Python is a fairly versatile programming language. It can be used to create all kinds of applications, from simple scripts to complex machine learning algorithms.

Debian 10 includes Python 3.7, which can be installed or upgraded using the apt tool.

At the time of writing, Python 3.8 is the latest major release of the Python language. It includes many new features such as assignment expressions, positional only parameters, f-string support, and more. Python 3.8 is not available in the standard Debian 10 repositories.

This article will show you how to install Python 3.8 on Debian 10. We will also show you how to create a virtual environment.

Installing Python 3.8 on Debian 10

Building Python 3.8 on Debian is a relatively straightforward process and only takes a few minutes.

  1. Start by installing the packages required to build Python source code:
    sudo apt update
    sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

  2. Download the latest source code from the Python download page using wget or curl. At the time of this writing, the latest release is 3.8.2:
    curl -O

  3. When the download is complete, unpack the archive:
    tar -xf Python-3.8.2.tar.xz

  4. Change to your Python source directory and run the configure script:
    cd Python-3.8.2./configure --enable-optimizations

    The script runs a series of checks to make sure all dependencies are present on your system. The –enable-optimizations option, which will optimize your Python binaries by running a few tests that will make the build process slower.

  5. Run make to start the build process:
    make -j 4

    Change -j to match the number of cores in your processor. You can find the number by typing nproc.

  6. Once the build is complete, install the Python binaries by running the following command as a user with sudo access:
    sudo make altinstall

    Don’t use the standard make install as it will overwrite the default system python3 binary.

  7. At this point Python 3.8 is installed on your Debian system and ready to use. You can check this by typing:
    python3.8 --version

    Python 3.8.2

Creating a virtual environment

The Python virtual environment is a self-contained directory tree that includes Python installation and a number of additional packages. This allows you to install Python modules in a project-specific isolated location rather than installing globally. This way, you don’t have to worry about the impact on other Python projects.

In this example, we will create a new Python 3.8 project named my_app inside the user’s home directory.

First, create a project directory and switch to it:

mkdir ~/my_app && cd ~/my_app

Inside the project root, run the following command to create a virtual environment named my_app_venv:

python3.8 -m venv my_app_venv

Activate environment:

source my_app_venv/bin/activate

Upon activation, the shell prompt will be prefixed with the environment name. Starting with Python 3.4, when pip building virtual environments, the package manager for Python is installed by default.

In a virtual environment, you can use pip instead of pip3.8 and python instead of python3.8:

python -v
Python 3.8.1

Once you are done with your work, type deactivate and you will be returned to your normal shell.



We showed you how to install Python 3.8 on Debian 10. You can now create a virtual environment and start developing your Python 3 projects.

If you have any questions or requests, feel free to comment below.