Verifying Python Installation on GNU/Linux
The installed Python version can be checked directly with the command python -V, which prints the interpreter's version string.
Why Verification Matters on Linux
On most GNU/Linux systems, Python is already installed as part of the base system, so checking a Python installation on Linux is normally a verification step rather than a fresh install. Unlike Windows or macOS, where you might download and run an installer, Linux distributions typically include Python by default. However, you still need to confirm it is present and know which version you have, because different projects may require different Python versions, and the system might have multiple versions installed side by side.
The Core Verification Command
To verify a Python installation on GNU/Linux, open a terminal and run the python command, checking that it starts without error. The most direct way to check the installed Python version is with the command python -V, which prints the interpreter's version string. The -V flag (uppercase V) is the standard flag for reporting version information.
The installed Python version can be checked directly with the command python -V, which prints the interpreter's version string.
Understanding the Terminal Interaction
Running the Version Check Command
You open a terminal on your GNU/Linux system and want to verify Python is installed and see which version you have.
- 1Open Terminal
Click on the terminal application in your system menu, or use a keyboard shortcut like Ctrl+Alt+T on many distributions.
- 2Type the Command
At the terminal prompt (usually shown as $ or #), type: python -V
- 3Press Enter
Press the Enter key to execute the command.
- 4Read the Output
The terminal displays the version string, such as 'Python 3.8.10' or 'Python 2.7.6', depending on what is installed on your system.
You now know that Python is installed and which version is active on your system.
Python, Python2, and Python3: Which Command to Use
On many GNU/Linux systems, you may have multiple Python commands available: python, python2, and python3. The python command is typically an alias that points to either python2 or python3, depending on the system configuration. The python2 command explicitly runs Python version 2.x, while python3 explicitly runs Python version 3.x. To check which version the generic python command points to, you can run python -V. If you need to verify a specific version is installed, use python3 -V or python2 -V directly. Most modern systems default python to python3, but this is not guaranteed, so always verify.
Interpreting the Version String
Running python -V in a terminal on a real GNU/Linux system printed the version string Python 2.7.6. The exact output depends on whichever Python version is actually installed on that machine. A modern system might show Python 3.8.10 or Python 3.10.12. The format is always Python followed by a major version number, a minor version number, and a patch/micro version number separated by dots. For example, in Python 3.8.10, the 3 is the major version, 8 is the minor version, and 10 is the patch version.
The version string format is always Python X.Y.Z, where X is the major version, Y is the minor version, and Z is the patch version. This tells you not only that Python is installed, but exactly which release you have.
Common Mistakes When Verifying Installation
Common mistake Using lowercase -v instead of uppercase -V
What it looks likepython -v (lowercase)Why it failsThe lowercase -v flag enables verbose output from the Python interpreter itself, which prints debugging information rather than just the version number. This produces many lines of output and is not the correct way to check the version.
Do this insteadUse python -V (uppercase) to get only the version string.
Common mistake Assuming python always refers to Python 3
What it looks likeRunning python -V and expecting Python 3.x output on an older system
Why it failsOn some GNU/Linux systems, the python command still points to Python 2.x. The generic python alias is not standardized across all distributions.
Do this insteadIf you need Python 3 specifically, use python3 -V. If you need Python 2, use python2 -V. Always verify which version the generic python command points to on your system.
Common mistake Typing the command incorrectly with spaces or special characters
What it looks likepython - V (with a space) or python--version (double dash)Why it failsThe terminal interprets these as different commands or arguments. python - V treats the dash as a separate argument, and python--version is not a recognized flag.
Do this insteadType exactly: python -V with no extra spaces between the command and the flag.
Common mistake Not opening a terminal before running the command
What it looks likeTrying to run python -V from a graphical file manager or text editor
Why it failsThe python command only works in a terminal or command-line environment. Graphical applications do not have access to the terminal command interpreter.
Do this insteadOpen a terminal application first, then type the command.
What If Python Is Not Installed?
If you run python -V and the terminal responds with a message like command not found or python: command not found, this means Python is not installed on your system or is not in your system's PATH. This is rare on most GNU/Linux distributions, but it can happen on minimal or embedded systems. In this case, you would need to install Python using your distribution's package manager (such as apt on Debian/Ubuntu, yum on Red Hat/CentOS, or pacman on Arch Linux). However, the focus of this article is verification on a system where Python is already present.
Practice: Verify Your Installation
Open a terminal on your GNU/Linux system and run the command python -V. Write down the exact output you see, including the version number. Then run python3 -V and python2 -V (if available) and note any differences. Which command on your system points to which Python version?
Hints
- Remember to use uppercase -V, not lowercase -v.
- If python2 is not found, that is normal on modern systems—Python 2 reached end-of-life in 2020.
- The terminal prompt is usually $ or #. Type your command after the prompt and press Enter.
Summary
- 1On GNU/Linux systems, Python is usually pre-installed, so verification is a confirmation step rather than a fresh installation.
- 2Use the command python -V (uppercase V) in a terminal to check the installed Python version.
- 3The python command may point to either Python 2 or Python 3 depending on your system; use python3 -V or python2 -V to check specific versions explicitly.
- 4The version string output follows the format Python X.Y.Z, where X is the major version, Y is the minor version, and Z is the patch version.
- 5Common mistakes include using lowercase -v, assuming python always means Python 3, and not running the command in a terminal.
At a glance
- Python is typically pre-installed on GNU/Linux systems; verification confirms its presence and version.
- The command python -V (uppercase V) reports the installed Python version in the terminal.
- The python command may point to Python 2 or Python 3; use python3 -V or python2 -V to check specific versions.
- Version strings follow the format Python X.Y.Z and tell you the exact release installed.
- Common errors include using lowercase -v, mistyping the command, or running it outside a terminal.