Skip to Content

3 ways to check Python version in Windows

Python is a programming language with many applications. It can be used for web development, data analysis, artificial intelligence, and more. Python is a popular language because it is easy to learn for beginners and has many modules and libraries that allow for robust programming. In this blog post, we will discuss three ways to check the version of Python in Windows.

What is Python?

Python is a high-level, general-purpose programming language created by Guido van Rossum. It was first released in 1991.

Before we can check what version of Python our computer has loaded, we must understand the version scheme of Python. Every Python version has three digits.

The first digit represents the major version, the second the minor version, and the third digit represents the micro version or “revision level.” For example, in Python 3.6.8, 3 is a major version, 6 is a minor version, and 8 is a micro version.

We must also note that major versions are typically not fully compatible with each other. In other words, software written with Python version 2.x.x may not run correctly with Python 3.x.x. However, minor releases are typically compatible with the previous releases. For example, code written in Python 3.1.x will run with Python 3.10.x (which is the current Python version).

Why do we need to Check Python version?

You may need to check your version of Python for a few reasons. Maybe you are following along with a tutorial that uses a specific version of Python or maybe you need to use a specific module or library that only works with certain versions of Python.

Checking your Python version is also a good way to make sure you have installed it correctly. Sometimes multiple versions of Python can be installed on a computer, and if you are not using the correct one, your code may not work as expected.

Check Python version in Windows with python -V command

The best way to check Python version in Windows is using python -V command. All we need is to open the command prompt and then type python -V. The Python version will be listed.  In some environments, the Python2.x series is assigned to python command, and the Python3.x series is assigned to python3 command.

If you see a message that says something like “python is not recognized as an internal or external command…” then that means Python is not installed on your system or Python is not added to the system path. You can download Python from the official website.

Check Python version in Windows with Python sys module

The sys module in Python provides various functions and variables that are used to manipulate different parts of the Python runtime environment. We can use sys.version to return a string containing the version of Python Interpreter with some additional information.

python -c “import sys; print(sys.version)”
3.6.8 (default, Mar 18 2021, 08:58:41)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

python -c “import sys; print(sys.version_info)”
sys.version_info(major=3, minor=6, micro=8, releaselevel=’final’, serial=0)

Check Python version in Windows with platform module

The platform module in Python is used to access the underlying platform’s data, such as, hardware, operating system, and interpreter version information.

platform.python_version() returns a string major.minor.patchlevel. It is useful when we want to get the version number as a simple string.

python -c “import platform; print(platform.python_version())”
3.6.8

python -c “import platform; print(platform.python_version_tuple())”
(‘3’, ‘6’, ‘8’)

We can also get more info with Python platform module.

  • platform.architecture() returns information about the bit architecture
  • platform.machine() returns the machine type, e.g. ‘i386’.
  • platform.node() returns the computer’s network name (may not be fully qualified!)
  • platform.platform()returns a single string identifying the underlying platform with as much useful information as possible.