How to check Python version on Ubuntu 26.04 LTS for beginners
Introduction
Ubuntu 26.04 LTS ships with Python 3 by default. Before writing Python code or installing Python packages, you should know the exact version of Python installed on your system. In this tutorial, you will learn how to check the Python version on Ubuntu 26.04 LTS.
Why check Python version on Ubuntu 26.04 LTS
Checking the Python version on Ubuntu 26.04 LTS helps ensure that your installed Python interpreter is compatible with the versions of the packages you want to use. For example, matplotlib 3.5 supports Python 3.7 and later, whereas matplotlib 3.10 requires Python 3.10 or later.
Prerequisites
Before following this tutorial, you need:
- A system running Ubuntu 26.04 LTS
Method 1: Check Python version on Ubuntu 26.04 LTS using the python3 –version command
To check Python version on Ubuntu 26.04 LTS using python3 --version, type:
python3 --version

Method 2: Check Python version on Ubuntu 26.04 LTS using the python3 -V command
To check Python version on Ubuntu 26.04 LTS using python3 -V, type:
python3 -V

Method 3: Check Python version on Ubuntu 26.04 LTS using the Python shell
The Python interactive shell provides information on the version of Python and also compilation details. To check Python version using the Python shell launch the Python interpreter with the following command.
python3

Method 4: Check Python version on Ubuntu 26.04 LTS using the sys module
The sys module can be used to check the Python version directly from within a script. This is useful for verifying that the system is running the required Python version before your application or script executes.
The -c option allows you to run Python code directly from the command line without creating a script. To check Python version using the sys module on Ubuntu 26.04 LTS, type:
python3 -c "import sys; print(sys.version)"

Method 5: Check Python version on Ubuntu 26.04 LTS using the platform module
Although commonly used for system information, you can also use the platform module to check the Python version. To check Python version with the platform module on Ubuntu 26.04 LTS type:
python3 -c "import platform; print(platform.python_version())"

How to locate the Python executable on Ubuntu 26.04 LTS
The python3 command can be configured to resolve to a different Python interpreter using tools such as update-alternatives. When working with multiple Python installations, locating the Python executable helps to identify which Python installation the python3 command is using.
For example one project may require Python 3.14 while another requires Python 3.10. Before creating the virtual environment for each project, you need to make sure the correct Python interpreter is used when invoking the python3 command.
To locate the Python executable that the python3 command resolves to on Ubuntu 26.04 LTS, type:
readlink -f "$(which python3)"

The above command finds the absolute path of the Python executable that will be run when you invoke python3.
- which python3: finds location of the
python3executable in your PATH. - $ (…) : runs the command inside the parentheses and substitutes its output into the outer command.
- readlink -f: resolves any symbolic link and prints the absolute path to the executable.
Final thoughts
In this tutorial you learned how to check the Python version on Ubuntu 26.04 LTS using the python3 --version command, the Python shell, and the sys and platform modules. In the next tutorial, you will learn how to create a virtual environment with Python 3.14 on Ubuntu 26.04 LTS.
