How to Install Python 3.8 on Debian 11 Bullseye

By default, Debian 11 Bullseye does not come with Python 3.8 in its repositories, unlike some other distributions such as Ubuntu. Python 3.9 is now the latest stable feature release series of Python 3, with Python 3.10 still in beta.

To run some applications or frameworks on Debian 11, you may need to install Python 3.8 on your system, for example, using the Swift programming framework given it built to utilize Ubuntu’s LTS versions that still run the older versions of Python by default. Python 3.8 is currently being worked on for security releases, but it is advisable to upgrade to newer versions if you are developing applications.

In the following tutorial, you will learn how to download the latest version of Python 3.8, compile and make it on your Debian 11 Bullseye operating system.


  • Recommended OS: Debian 11 Bullseye
  • User account: A user account with sudo privilages or root access (su command).
  • Required Packages: wget

Updating Operating System

Update your Debian 11 operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade

Root or Sudo Access

By default, when you create your account at startup with Debian compared to other distributions, it does not automatically receive sudoers status. You must either have access to the root password to use the su command or visit our tutorial on How to Add a User to Sudoers on Debian.

Install Python 3.8

Once you have got the download link, use the wget command to download the Python 3.8 archive:


Extract the Python archive. Remember, change the version number if you downloaded a newer one:

tar -xf Python-3.8.12.tar.xz
mv Python3.8.12 /opt/Python3.8.12

Now install the dependencies required to install Python 3.8:

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

Navigate to the directory and run the ./configure –enable-optimizations command:

cd /opt/Python3.8.12/
./configure --enable-optimizations --enable-shared

Note, The script performs several checks to make sure all of the dependencies on your system are present. The ./configure –enable-optimizations will optimize the Python binary by running multiple tests, which will make the build process slower.

Now that you have built and configured the environment, it is time to compile it with the command make.


A handy trick is to specify the -j <number of cpu> as this can significantly increase compiling speed if you have a powerful server. For example, the LinuxCapable server has 6 CPUs, and I can use all 6 or at least use 4 to 5 to increase speed.

make -j 6

Once you have finished building, install Python binaries as follows:

sudo make altinstall

Note, it’s advised to use the make altinstall command NOT to overwrite the default Python 3 binary system.

See also
How to Upgrade from Debian 11 Bullseye to Debian 12 Bookworm

Next, after the installation, you need to configure the dynamic linker run-time bindings:

sudo ldconfig /opt/Python3.8.12

Note, do not skip this, or you will face issues. You will also need to replace the path with your directory name and version.

Confirm that Python 3.8 is installed and the build version by running the following command:

python3.8 –version

Example output:

Python 3.8.12

Create a Virtual Environment

Python’s venv module is a virtual environment is a Python environment such that the Python interpreter, libraries, and scripts installed into it are isolated from those established in other virtual environments, and (by default) any libraries installed on your operating system, for example, those that are installed on your Ubuntu operating system to avoid clashing and disturbing your production environments.

To make sure Python 3.8 is installed correctly and functioning, create a quick Python project as follows.

First, create the project directory and navigate to it:

mkdir ~/test_app && cd ~/test_app

Now inside the project root directory, run the following command to create a virtual environment, for the test name it test_app:

python3.8 -m venv test_app_venv

Next, activate the virtual environment as follows:

source test_app_venv/bin/activate

After starting the virtual environment you will now be in the shell prompt terminal. You will notice the name of your environment will be prefixed.


(test_app_venv) root@debian:~/test_app# 

To exit the virtual environment, use the following command:


Python 3.8-PIP

By default, PIP 3.8 should be installed. For those with PIP issues, an alternative method is to install the package manager manually.

This can be done in several ways. One of the most common is as follows.

Log back into your environment, then download using the wget command.


Next, install the file downloaded.


Once installed, it is a good idea to check for upgrades.

python3.8 -m pip install --upgrade pip

Now verify the PIP 3.8 version installed:

(test_app_venv) root@debian:/opt/Python3.8.12# pip3.8 --version
pip 21.2.4 from /opt/Python3.8.12/test_app_venv/lib/python3.8/site-packages/pip (python 3.8)

Comments and Conclusion

You have learned how to install Python 3.8 for Debian 11 Bullseye in the tutorial and create an immediate virtual environment. Overall, it is advised if you are in development to move to Python 3.9 in the future, but using Python 3.8 is still safe as the Python Software Foundation is maintaining it.

6 thoughts on “How to Install Python 3.8 on Debian 11 Bullseye”

  1. Hi there, Thanks for the detailed explaination on how to install Python3.8.12 from tar file. So now that we don’t have pip available in the python installed like this how do I install any python packages like for example apache-airflow on this virtual environment? Is there any easier to get this done with? Any advice is appreciated. Thanks

  2. Hi Shahaja,

    Updated the guide, also tested with installing apache-airflow which worked. Hope it helps a bit.

    Output from install:

    Successfully installed Babel-2.9.1 Flask-Babel-1.0.0 Flask-JWT-Extended-3.25.1 Flask-OpenID-1.3.0 Flask-SQLAlchemy-2.5.1 Mako-1.1.5 WTForms-2.3.3 alembic-1.7.3 anyio-3.3.2 apache-airflow-2.1.4 apache-airflow-providers-ftp-2.0.1 apache-airflow-providers-http-2.0.1 apache-airflow-providers-imap-2.0.1 apache-airflow-providers-sqlite-2.0.1 apispec-3.3.2 argcomplete-1.12.3 attrs-20.3.0 blinker-1.4 cattrs-1.5.0 certifi-2021.5.30 cffi-1.14.6 charset-normalizer-2.0.6 click-7.1.2 clickclick-20.10.2 colorama-0.4.4 colorlog-5.0.1 commonmark-0.9.1 croniter-1.0.15 cryptography-35.0.0 defusedxml-0.7.1 dill-0.3.4 dnspython-2.1.0 docutils-0.16 email-validator-1.1.3 flask-1.1.4 flask-appbuilder-3.3.3 flask-caching-1.10.1 flask-login-0.4.1 flask-wtf-0.14.3 graphviz-0.17 gunicorn-20.1.0 h11-0.12.0 httpcore-0.13.7 httpx-0.19.0 idna-3.2 importlib-metadata-4.8.1 importlib-resources-1.5.0 inflection-0.5.1 iso8601-0.1.16 isodate-0.6.0 itsdangerous-1.1.0 jinja2-2.11.3 jsonschema-3.2.0 lazy-object-proxy-1.6.0 lockfile-0.12.2 markdown-3.3.4 markupsafe-1.1.1 marshmallow-3.13.0 marshmallow-enum-1.5.1 marshmallow-oneofschema-3.0.1 marshmallow-sqlalchemy-0.23.1 numpy-1.21.2 openapi-schema-validator-0.1.5 openapi-spec-validator-0.3.1 pandas-1.3.3 pendulum-2.1.2 prison-0.2.1 psutil-5.8.0 pycparser-2.20 pygments-2.10.0 pyjwt-1.7.1 pyrsistent-0.18.0 python-daemon-2.3.0 python-dateutil-2.8.2 python-nvd3-0.15.0 python-slugify-4.0.1 python3-openid-3.2.0 pytz-2021.3 pytzdata-2020.1 pyyaml-5.4.1 requests-2.26.0 rfc3986-1.5.0 rich-10.11.0 setproctitle-1.2.2 six-1.16.0 sniffio-1.2.0 sqlalchemy-1.3.24 sqlalchemy-jsonfield-1.0.0 sqlalchemy-utils-0.37.8 swagger-ui-bundle-0.0.9 tabulate-0.8.9 tenacity-6.2.0 termcolor-1.1.0 text-unidecode-1.3 unicodecsv-0.14.1 urllib3-1.26.7 werkzeug-1.0.1 zipp-3.6.0

  3. This howto came very handy when the 3D printing application cura refused to build with python 3.9 and insisted on python version 3.8 . Even though I kind of know the single steps, it would have taken me some time to get them right. Thank you for the compilation. It worked flawlessly on my bullseye machine.

  4. Thank you, this was superhelpful.
    i was finally able to install Svp4Linux with Svptube on newer Debian 11, because it relies specifically on libpython3.8 … might come in handy also for other situations, great!


Leave a Comment

Share to...