How to Check Python Version in Windows

We can check the Python version installed on Windows 10 by opening up a Command Prompt and typing the following command:

python -V
windows check python version

If you want to check the Python version inside the Python interpreter, you can do this by importing the sys module. Open the command prompt (or PowerShell) and type python to open the interpreter.

Then, after starting the Python shell, import the sys module and then run the print(sys.version_info) command.

import sys
print(sys.version_info)

If the command print your Python version has the major=3 attribute, it means that you are running a Python 3 on your Windows 10 computer.

how to check python version in windows script

Just to print the major version, execute the following command:

print(sys.version_info.major)

You can also use the sys module to check the Python version in a script like this:

import sys

python_version = sys.version.split()[0]
print(python_version)

The preceding script sys.py will print the version number of the Python that runs its code. This script uses the split() method of the sys.version module to get the Python’s version number.

check python version windows