How to Check Python Version on Windows, macOS and Linux

If you want to know how to check Python version, open a terminal and run python --version. On Windows, py --version is often the most reliable choice; on macOS and Linux, use python3 --version if python is unavailable or points somewhere unexpected. The result will look similar to Python 3.14.7, although your installed version may differ.

Quick answer: Run py --version on Windows or python3 --version on macOS and Linux. To check the interpreter actually running a script, use import sys; print(sys.version).

How to check Python version: the quickest commands

Python includes a version option in its command-line interface. The official Python command-line documentation defines both -V and --version as options that print the interpreter version and exit. In most cases, the long form is easier to recognise and remember.

System or situationTry this firstUseful alternative
Windowspy --versionpython --version
macOSpython3 --versionpython --version
Linuxpython3 --versionpython --version
Inside a running scriptsys.version_infoplatform.python_version()
Confirm the exact executablesys.executablewhich python3 or where python
python --version
python3 --version
py --version

You only need one command that works in your environment. If more than one works, the commands may refer to different installations, so compare their results before installing packages or running a project.

Check the Python version on Windows

Steps to check Python version on Windows using PowerShell, Command Prompt and the py launcher
On Windows, run py --version in PowerShell or Command Prompt; py list shows installed versions.

Open PowerShell, Windows Terminal or Command Prompt, then run:

py --version

The py command is designed to locate and launch Python on Windows. With the current Python install manager, the official Windows documentation says that py list shows the installed runtimes and identifies the current one:

py list

You can also try:

python --version

If py --version and python --version report different numbers, you have more than one interpreter or a command alias is resolving to another location. That is not necessarily an error. It means you should identify which executable your project uses before installing dependencies.

Check the Python version on macOS or Linux

How to check Python version on macOS and Linux with the python3 --version command
On macOS and Linux, python3 --version usually identifies the active Python 3 interpreter.

Open Terminal and run:

python3 --version

The python3 name is common on Unix-like systems because it distinguishes Python 3 from older system arrangements. If the command is not present, try:

python --version

Do not assume that python and python3 are interchangeable. Run both if they exist and note the output. A project, shell configuration, package manager or virtual environment can change which executable each name selects.

How to check Python version inside a script

Python code examples using sys.version, sys.version_info and platform.python_version
Check Python from inside a script with sys.version, sys.version_info or platform.python_version().

A terminal command checks the interpreter selected by that shell command. Code executed by an IDE, notebook, service or virtual environment may use a different interpreter. To inspect the Python process that is actually running your code, import sys:

import sys
print(sys.version)

sys.version is a human-readable string containing the version plus build and compiler details. The official sys documentation advises against parsing that string to make program decisions. Use sys.version_info for reliable comparisons:

import sys
print(sys.version_info)
if sys.version_info < (3, 10):
    raise RuntimeError("This project requires Python 3.10 or newer")

sys.version_info behaves like a tuple whose fields include major, minor and micro. You can therefore check a minimum supported release without extracting digits from formatted text.

If you only want a clean dotted version string, use the standard-library platform module:

import platform
print(platform.python_version())

According to the official platform documentation, platform.python_version() returns a major.minor.patchlevel string. It is convenient for display and logging, while sys.version_info remains the better choice for conditional logic.

Which Python interpreter are you checking?

Commands to identify the active Python interpreter and virtual environment path
Use which python3, where python or sys.executable to confirm which interpreter is actually running.

Version confusion usually comes from checking one interpreter and running another. This is common when several Python releases, an IDE and one or more virtual environments are installed on the same computer.

On macOS or Linux, locate the command with:

which python3
which python

On Windows, use:

where python

For the most direct answer from inside the active Python process, print sys.executable:

import sys
print(sys.executable)

The returned path tells you exactly which executable is running. If a virtual environment is active, the path should normally point inside that environment. A virtual environment is built on a base Python installation but has its own isolated package location, so its interpreter path can differ from the system default.

Check the Python version used by pip

The pip --version output includes a package location and the Python release associated with that pip command. A safer habit is to run pip through the exact interpreter you intend to use:

python -m pip --version
python3 -m pip --version
py -m pip --version

This avoids a frequent mismatch in which pip installs a package for one interpreter but the script runs under another. If that mismatch produces an import error, the guide to fixing Python “No Module Named Requests” explains how to align the interpreter and package installation.

Check Python in an IDE or Jupyter notebook

An IDE such as VS Code or PyCharm can select a project interpreter independently of your normal terminal. A Jupyter notebook also runs through its selected kernel. In either environment, execute Python code rather than relying only on a separate system terminal:

import sys
print(sys.version)
print(sys.executable)

The first line identifies the runtime version; the second identifies its executable path. Together they answer both “which version?” and “which installation?” If you are confirming a fresh setup, you can then run a minimal program from the Python Hello World beginner’s guide.

What to do when the version command does not work

Troubleshooting Python version commands that do not work or report the wrong interpreter
Try the platform-specific command, list installed versions and check sys.executable when results differ.

“Python was not found” or “command not found”

First try the platform alternatives: py --version on Windows and python3 --version on macOS or Linux. If none works, Python may not be installed or its executable directory may not be available on your shell’s PATH. Install Python from a trusted distribution and open a new terminal before checking again.

The command opens a store or installer

On Windows, command aliases and the Python install manager can affect what happens when you type python. Try py --version and py list to inspect the runtimes managed by the Python launcher or install manager.

Two commands show different versions

This normally indicates multiple installations, not corrupted output. Compare where python on Windows or which python and which python3 on macOS and Linux. Then run sys.executable from your project to see which one matters.

The terminal and IDE show different versions

Check the IDE’s interpreter or Jupyter kernel selection. Confirm the result by running print(sys.executable) in the same console, script or notebook where the project runs.

Why the Python version matters

The major, minor and patch numbers communicate different levels of change. In a version such as 3.14.7, 3 is the major release, 14 is the minor release and 7 is the patch release. Projects often define a minimum minor version because syntax and standard-library features evolve. Patch releases generally deliver compatible corrections within the same minor series.

Checking the exact runtime helps you:

  • confirm that a tutorial or dependency supports your interpreter;
  • diagnose syntax errors caused by newer language features;
  • match pip installations to the interpreter running the project;
  • reproduce behaviour across local, test and production environments;
  • verify that an IDE or virtual environment selected the intended Python installation.

Frequently asked questions

What is the simplest way to check Python version?

Run python --version in a terminal. If that command is unavailable, use py --version on Windows or python3 --version on macOS and Linux.

How do I check Python version in code?

Use sys.version_info when your program needs to compare versions. Use sys.version for detailed display information or platform.python_version() for a clean dotted string.

How can I see every Python version installed on Windows?

Run py list. Then use py --version to see the current default selected by the Windows Python launcher or install manager.

Why does my IDE use a different Python version?

IDEs and notebooks can select a project interpreter or kernel that differs from the shell default. Run print(sys.executable) inside the IDE to reveal the active executable.

Does pip --version show the Python version?

Usually, yes: its output identifies the associated Python release and package path. Prefer python -m pip --version so the pip check is tied to a specific interpreter.

Bottom line

To check Python quickly, use py --version on Windows or python3 --version on macOS and Linux. When accuracy matters for a project, also print sys.version_info and sys.executable from the running code. That combination confirms both the version number and the precise interpreter behind it.