How to Check Python Version on Linux and Windows

LightNode
By LightNode · · Updated

Quick Answer: How to Check Your Python Version

To check which version of Python is installed, open a terminal or command prompt and run one of these commands:

  • Linux: python3 --version
  • macOS: python3 --version
  • Windows: python --version (or py --version using the Python launcher)

The command prints a line such as Python 3.12.4 or Python 3.13.1. As of 2026, Python 3.12 and 3.13 are the current stable releases, so most up-to-date systems will report a version in that range. On many modern Linux distributions and on macOS, the standalone python command no longer exists at all (Python 2 has been end-of-life since January 2020) — use python3 instead.

Other quick options:

  • Check Python 3 explicitly on any platform: python3 --version

  • On Windows, list every installed version with the launcher: py --list

  • From inside a running Python session, print full details with:

    import sys
    print(sys.version)
    

The rest of this guide explains each method in detail for Linux, Windows, and macOS.

Introduction

Python is one of the most widely used programming languages, making it essential for developers to know the version installed on their system. The version of Python can affect the compatibility of scripts, libraries, and even the behavior of the language itself. In the current Python 3.12/3.13 era (2026), staying on a supported release also matters for security updates and for the newest language features.

Checking the Python version is a straightforward task, but the process differs slightly between operating systems. On Linux and macOS, you typically use the terminal to check the version, while on Windows, you can use the Command Prompt (or PowerShell) and the Python interpreter directly.

Note that Python 2 reached end-of-life in January 2020, so today the python3 command is the standard on Linux and macOS. Some systems no longer ship a bare python command at all. Windows installers instead provide both python and the py launcher.

This guide will walk you through how to check the installed Python version on Linux, Windows, and macOS systems, helping you ensure your environment is set up correctly for your Python projects.

Checking Python Version in Linux

On Linux, checking the Python version is quick and easy using the terminal. Below are the different methods you can use to verify which version of Python is installed on your system.

Using the Terminal

Default Python Version

To check the default version of Python installed, simply open the terminal and run the following command:

python --version

or

python -V

On modern Linux distributions (2026), python usually points to Python 3, and the command returns something like Python 3.12.4. On some older systems this may still return a Python 2.x version, and on many current distributions the bare python command is not installed at all — in that case use python3 (shown below).

Python 3 Version

python3 is the standard command on today's Linux systems. To check the version of Python 3 explicitly, use the following command:

python3 --version

This will output the version of Python 3.x installed on your system.

Alternate Command

In some Linux distributions, the python command might be linked to Python 3 instead of Python 2. In this case, you can simply use the following:

python --version

and it will display the Python 3 version.

Using the Python Interpreter

If you prefer to check the version from within the Python environment itself, you can do so by starting the Python interpreter.

  1. Open the terminal.

  2. Type python or python3 (depending on the version you want to check) and press Enter:

    python
    
  3. Once inside the interpreter, type the following code to check the Python version:

    import sys
    print(sys.version)
    
  4. The version will be displayed in the format: 3.x.x (default, ...) or 2.x.x (default, ...).

  5. Exit the interpreter by typing:

    exit()
    

Checking Python Version in Windows

In Windows, you can check the Python version through the Command Prompt or the Python interpreter. Here's how you can do it on a Windows machine:

Using Command Prompt

To check the version of Python installed, open the Command Prompt and use the following commands:

Default Python Version

Open the Command Prompt by pressing Windows + R, typing cmd, and pressing Enter. Then, type the following command:

python --version

or

python -V

This will output the version of Python that's set as the default, for example Python 3.12.4. You can run the same command in PowerShell.

Using the Python Launcher (py)

Modern Windows installers include the Python launcher, py. It's often the most reliable way to check versions, especially when several versions of Python are installed:

py --version

To list every Python version detected on the system, run:

py --list

If Python is Not Found

If the command python does not work and the terminal returns an error saying that Python is not recognized as an internal or external command, it means that Python is either not installed or it is not added to the system’s PATH.

In this case, you can check for Python 3 with the following command:

python3 --version

This command works if Python 3 is installed and properly set up in your PATH.

Using the Python Interpreter

You can also check the Python version directly from the Python interpreter:

  1. Open Command Prompt (cmd).

  2. Type python and press Enter. This will start the Python interpreter.

    python
    
  3. Once inside the interpreter, check the version by typing:

    import sys
    print(sys.version)
    

    This will display the full Python version along with some additional details.

  4. Exit the interpreter by typing:

    exit()
    

Checking Python Version on macOS

macOS behaves much like Linux because it also uses a Unix-based terminal. Open the Terminal app (found in Applications > Utilities, or via Spotlight) and use the same commands.

Using the Terminal

Modern versions of macOS no longer include a system python (Python 2) command, so use python3:

python3 --version

This returns a line such as Python 3.12.4. If you installed Python through Homebrew or the official python.org installer, this reflects that installation.

To find which Python 3 executable is being used, run:

which python3

Using the Python Interpreter

You can also check from within the interpreter, just as on Linux:

  1. Open the Terminal app.

  2. Start Python by typing python3 and pressing Enter.

  3. Inside the interpreter, run:

    import sys
    print(sys.version)
    
  4. Exit with exit().

Checking Python Version in Linux and Windows

FAQs

Q: What if the 'python' command is not recognized?

A: If the python command is not recognized, it likely means that Python is either not installed or not added to your system's PATH environment variable.

  • On Windows, ensure that during Python installation, the option "Add Python to PATH" is selected. If it's already installed and not in the PATH, you may need to manually add the Python installation directory to your system's PATH.

  • On Linux, Python may not be installed at all, or you may be using a distribution where Python 3 is installed as python3 rather than python. Try using the command python3 --version instead.

  • On macOS, recent versions no longer ship a bare python command. Use python3 --version, and install Python via Homebrew or the official python.org installer if it's missing.

  • On Windows, you can also try the Python launcher with py --version if python isn't recognized.

Q: How do I check if both Python 2 and Python 3 are installed on Linux?

A: On many Linux systems, Python 2 and Python 3 are both installed, but they may be accessed via different commands:

  • To check Python 2, run:
    python --version
    
  • To check Python 3, run:
    python3 --version
    

If both versions are installed, you'll see their respective versions displayed.

Q: Can I check the Python version from a script?

A: Yes, you can check the Python version from within a script. To do so, include the following code in your Python script:

import sys
print(sys.version)

This will print the Python version used to run the script, along with additional details.

Q: How do I find the path to the Python executable?

A: You can find the path to the Python executable using the following commands:

  • On Linux and macOS:

    which python
    

    or

    which python3
    
  • On Windows:

    where python
    

    or, with the Python launcher:

    py --list-paths