Not sure what Python version you’re running? In this short how-to, you’ll learn how to check your Python version. You don’t want to be running an old version unintentionally, even though you just installed the latest! Yes, this happens. It’s easy to check the Python version, so let’s do that.
Check Python version
Assuming you have Python installed, and the terminal open, you can check your current Python version with the following command. On macOS and Linux, use python3:
$ python3 --version Python 3.15.2
On Windows, the command is python, or py if you installed Python with the Python install manager:
C:\> python --version C:\> py --version
You can also type -V instead of --version; it does the same thing.
If you get an error like “command not found” or “Python was not found”, Python isn’t installed or isn’t on your PATH. Follow the steps on installing Python for your operating system.
Is your version still supported?
Python gets a new version every October, and each version gets bug and security fixes for five years. Python 3.15 is the current release. Python 3.10 reached its end of life in October 2026, so if your version is lower than 3.11, it no longer gets security fixes and you should upgrade. The official Python versions page shows the status of each version.
If python --version says something like Python 2.7.18, you’re on a very old system or a system where python still points to Python 2. Python 2 reached its end of life in January 2020. Use python3 instead, and install a current Python 3 if you don’t have one.
Get more details
Add a second V to see when and how your Python was built:
$ python3 -VV Python 3.15.2 (main, Oct 25 2026, 16:57:51) [Clang 21.0.0 (clang-2100.3.34.2)]
The part between brackets shows the compiler, so your output will look a little different depending on your operating system.
Check the Python version from code
Sometimes you want to know the version from inside a Python program, for example to print it in a bug report. The sys module has two ways to get it. Start the REPL and try this:
>>> import sys >>> sys.version '3.15.2 (main, Oct 25 2026, 16:57:51) [Clang 21.0.0 (clang-2100.3.34.2)]' >>> sys.version_info sys.version_info(major=3, minor=15, micro=2, releaselevel='final', serial=0)
sys.version is a string meant for humans. sys.version_info is a named tuple, which makes it the one to use in code, because you can compare it with a tuple:
>>> sys.version_info >= (3, 12) True >>> sys.version_info.minor 15
If you only need the version number as a string, use the platform module:
>>> import platform >>> platform.python_version() '3.15.2'
Want your script to stop with a clear message on a version that’s too old? That’s explained in Check Python version in code: require a minimum.
When you have more than one Python installed
Many computers have more than one Python. macOS and Linux often come with a system Python, and you may have installed a newer one next to it. The python3 command runs whichever one comes first on your PATH. To see all of them on macOS and Linux, use:
$ which -a python3
Each line is the path to a python3 command; the first one is the one that runs. To check a specific one, call it with its full path, for example /usr/bin/python3 --version.
On Windows, the Python install manager keeps track of every version it installed. py list lists them, and py -V:3.14 --version runs a specific one. The official Windows documentation has the details.
C:\> py list
If you use uv, uv python list --only-installed shows every Python that uv can find on your computer, including the ones it installed itself. With PyEnv, use pyenv versions.
One more thing: inside an activated virtual environment, python runs the Python that the environment was created with. So if the version looks wrong, check whether a virtual environment is active.