Python lets you run scripts and applications on Debian. This guide installs Debian 12’s packaged Python 3 and creates a separate environment for an application’s dependencies.

Install Python 3

You need a Debian 12 server and an account with sudo access.

  1. Refresh the package list:

    sudo apt update
  2. Install Python and virtual environment support:

    sudo apt install python3 python3-venv
  3. Check the installed version:

    python3 --version

Debian 12 provides Python 3.11 through its standard repositories. Repository updates may change the package revision without changing the major Python version.

Create an application environment

In your application directory, run:

python3 -m venv .venv
source .venv/bin/activate
python --version

While this environment is active, install the dependencies your application requires using python -m pip. Run deactivate when finished.

Keep Debian’s system Python intact. Ubuntu PPAs such as Deadsnakes are not Debian repositories, and replacing the operating system’s Python can break system tools. If an application needs a different maintained Python version, use an isolated installation supported by that application.