Check if Python Is Installed in Windows

  1. Check if Python Is Installed in Windows Using the py Command
  2. Check if Python Is Installed in Windows Using py --version Command
  3. Check if Python Is Installed in Windows Using where Command

This tutorial will look into the multiple ways to check if Python is installed in Windows. We can check if Python is installed in Windows using three commands which are explained below.

Check if Python Is Installed in Windows Using the py Command

When we execute the py command in the Windows Command Prompt, it first displays the details of the latest version installed on the computer and then runs/starts the installed version.

If we need to check if some version of Python, i.e., Python 2 or 3, is installed, we can do so using the following command.

For Python 2.x,

py -2

For Python 3.7,

py -3.7

If the specified version of Python is not installed, the command will first return the not found error and then return all the installed versions of Python installed by the py launcher.

C:\WINDOWS\system32>py -2.5
Python 2.5 not found!
Installed Pythons found by py Launcher for Windows
 -3.8-32 *
 -3.7-64
 -2.7-64

Requested Python version (2.5) not installed, use -0 for available pythons

And if the py launcher is not installed, the following error will be returned.

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

Check if Python Is Installed in Windows Using py --version Command

We can also check what version of Python 2 or 3 is installed using the following command.

py --version

The above command will return the latest version installed on the computer and will not start it. We can also check if some specific version of Python is installed in the following way.

py -2 --version

It will return the latest version of Python 2 installed on the computer. If the Python version specified in the command is not installed, like the py command, it will return all the versions installed on the computer.

Check if Python Is Installed in Windows Using where Command

The Windows where command is used to search and display files in a directory tree. The command searches for the given pattern in the current directory and the paths specified in the PATH environment variable.

The where command is handy to locate the multiple versions of the same command in the PATH environment variable. So, if we look for python using the where command, it will return the paths of all the copies of python.exe.

C:\WINDOWS\system32>where python
C:\Python27\python.exe
C:\Users\Waiz\AppData\Local\Programs\Python\Python37\python.exe
C:\Users\Waiz\AppData\Local\Programs\Python\Python38-32\python.exe

If Python is not installed on the computer, the where command will return the following error.

INFO: Could not find files for the given pattern(s).
Contribute
DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.