How to Check Python Version Guide

The fastest way to check your Python version is to run python --version or python -V in a terminal. On macOS and Linux, you may need python3 --version. On Windows, py --version and py list can help when multiple Python versions are installed.

python --version
python -V
python3 --version

Typical output looks like this:

Python 3.14.0

Quick commands

Where you are checking Command or code
Windows, macOS, or Linux terminal python --version
macOS or Linux when python is not Python 3 python3 --version
Windows with Python install manager or launcher py --version
Windows list installed runtimes py list or py -0p
Inside Python code sys.version_info
Short string inside Python code platform.python_version()

Check Python version in Windows

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

python --version

If Windows uses the Python install manager or launcher, these commands are also useful:

py --version
py list
py -0p

py list shows installed runtimes managed by the Python install manager. The legacy py -0p form is still useful on systems that have the older launcher behavior and can show installed versions with paths.

If Windows says Python is not recognized, Python may not be installed, the launcher may not be installed, or the install directory may not be on PATH. Use the Python installer from python.org/downloads, then reopen the terminal.

Check Python version in macOS

Open Terminal and try:

python3 --version

Some environments also provide python:

python --version

If both commands exist, they may point to different interpreters. Use which to see the path:

which python3
which python

Check Python version in Linux

Most Linux systems use python3 for Python 3:

python3 --version

If you work inside a virtual environment, activate it first and then run:

python --version
python -m pip --version

The python -m pip --version command is useful because it shows which Python interpreter is connected to that pip.

Show detailed build information

Use -VV when you need more detail than the normal version number:

python -VV

This can include build information such as compiler and build date, depending on the interpreter.

Check Python version inside a script

Use sys.version_info when your code needs to compare versions. It is structured and safer than parsing a string.

import sys

if sys.version_info < (3, 10):
    raise RuntimeError("Python 3.10 or newer is required")

print(sys.version_info.major)
print(sys.version_info.minor)
print(sys.version_info.micro)

Use sys.version when you want the full human-readable version string:

import sys

print(sys.version)

If you only need the short version string, use platform.python_version():

from platform import python_version

print(python_version())

Check Python version from one command

You can run a short Python snippet directly from the command line:

python -c "import sys; print(sys.version)"
python -c "import platform; print(platform.python_version())"

On macOS or Linux, replace python with python3 if needed.

Check Python version in Jupyter Notebook

Run this in a notebook cell:

import sys

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

sys.executable is important in notebooks because the notebook kernel may use a different Python installation than your terminal.

Understand major, minor, and micro versions

Python versions normally follow this shape:

MAJOR.MINOR.MICRO

For example, in Python 3.12.4, 3 is the major version, 12 is the minor version, and 4 is the micro version. Most compatibility checks care about major and minor versions, such as Python 3.10 or newer.

If you want a broader explanation of how Python runs code, see Is Python compiled, interpreted, or both?

Common problems

  • python and python3 show different versions. This means they point to different executables. Use which python3, which python, or Windows where python to inspect paths.
  • pip installs packages into the wrong Python. Prefer python -m pip install package so pip is tied to the interpreter you just checked.
  • A virtual environment shows a different version. That is normal. Activate the virtual environment before checking if you care about the project version.
  • A script runs under a different Python than your terminal. Check the shebang line, file association, IDE interpreter setting, or notebook kernel.

For simple local testing after confirming your interpreter, you may also find the Python HTTP server guide useful.

Official references

The Python documentation covers the command-line -V and --version options, the Windows Python install manager, sys.version, sys.version_info, and platform.python_version().

Conclusion

Use python --version or python3 --version for a quick terminal check. Use py list on Windows when multiple runtimes are installed. Inside code, prefer sys.version_info for comparisons and platform.python_version() when you need a short version string.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted