How to find python version on Debian

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to find python version on Debian.

If you don't know which version of python you are running on your Debian machine, you can easily find out.

You can find out version of python by using the terminal, via one single command. The version command can display the version of the app, in this case python.

Python3 is already installed on your Debian machine.However, if you are not aware of python version that your system came with, then simply follow the steps below to find out.

Step 1 - Check if python is installed

First thing that you need to do is to check if Python is installed on your machine.

Python comes preinstalled on Debian distros. However, to make sure that your machine has Python on it, run the command below.

which python3

which command can be used to check if python binary is found on your machine, that way you can easily find out if python is installed on your machine. For example, in our case python3 is installed , and which command shows us where python3 binary is.

If Python is not installed on your machine, you can easily install it via the apt package manager, as python3 is available on Debian repositories.

In this tutorial, we are using Debian 12 "Bookworm".

So to install Python simply run.

sudo apt install python3

Step 2 - Check python version

Find Python version via Terminal

One way of finding the version of python that is running on your machine, is by using the version command.

For example, to check which python version simply run the following.

python3 --version

And it will display python version on your terminal, as shown in the screenshot below.

Find Python version using Python

The version command is not the only way to find out python version. You can also use Python script to find out which version of Python.

Let's say that you are building a python script that is supposed to perform an action if specific python version is running on the system, to do this, you can use sys module on Python.

For example, to find python version by using sys module, run the following python code.

#!/usr/bin/env python3

import sys

print("Python version is", sys.version)


In this tutorial, you learned how to find python version on Debian.