How to Check Version of Installed Python from cmd in Windows?

Let us see how to use cmd (Command Prompt) to determine which version of Python is installed on your Windows OS system.

Checking Python Version from cmd in Windows

Steps to be followed:

  • To access the command line, first right-click the Windows logo in the bottom left corner of your computer screen and pick “Command Prompt” from the list. (OR)
  • Simply type “cmd” into the Windows search box and select the first option that appears in the search results.
  • Now, in the Command Prompt window, enter the following command:
  • python --version (OR)
    python
  • Press Enter

Thus, if Python is installed on your system and the path is also specified in the Environment Variables, the first command will directly display the version of Python installed on your operating system, as shown below.

When you type the first command python –version it directly displays the version

C:\Users\VIKRAM>python --version
Python 3.9.1

If you run the second command, “python,” this command will run Python.exe and display the version number as shown below:

C:\Users\VIKRAM>python
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Checking Python version in Windows

If Python is not properly installed on your machine, you will observe the following:

'python' is not recognized as an internal or external command, operable program or batch file.

In this scenario, you must first download Python from https://www.python.org/downloads/ and add it to your path.

Check Python version Using sys.version Method

For this approach, the user must import the sys library and use the from sys.version command, which returns the user’s current Python version.

# Import sys module using the import keyword
import sys
# Get the current version of the user using the sys.version command
print("User Current Version:-", sys.version)

Output:

Current Version of User : 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]

Checking Python version using sys module

Check Python version Using python_version() Method

This function can be accessed by importing the platform library and will always return the running user’s Python version as a string.

# Import python_version from platform module using the import keyword
from platform import python_version
# Get the current version of the user using the python_version() function
print("User Current Version:-", python_version())

Output:

User Current Version:- 3.7.12

Check Python version Using python -V command

This approach is one of the easiest of all the methods since it uses one of the built-in commands in Python to obtain the current Python version.

command:

python -V

Output:

C:\Users\VIKRAM> python -V
Python 3.9.1