84

Please note I'm not asking "how to check which version of Python did I install".

I've installed several versions of Pythons on my Windows computer, for example Python 2.7-64, Python 2.7-32, and Python 3.7-32.

Python 3 includes "py" and "pyw" which helps me to easily start different Pythons, for example:

  • "py -2.7" starts Python 2.7-64
  • "py -2.7-32" starts Python 2.7-32
  • "py -3.7-32" starts Python 3.7-32

What I'm wondering is, how to check how many different versions of Python did I install on my Windows PC and what versions are they?

PyCharm is able to find it but, for one thing, I don't know if it is a complete list, and for another, I wonder if there is any tool provided by Python or the operating system can do it.

Next-Door Tech
  • 171
  • 1
  • 1
  • 13
Vespene Gas
  • 3,210
  • 2
  • 16
  • 27
  • 1
    If you use conda to install the versions, type conda env list in your cmd. [Link to conda doc](https://conda.io/docs/user-guide/tasks/manage-environments.html#viewing-a-list-of-your-environments) – Melvin Nov 15 '18 at 04:55
  • What if you have a look at the list of installed programs ? You may have one entry for each python version. – Patol75 Nov 15 '18 at 05:45
  • @Patol75 I'm using Microsoft Window 10. In my "Start" menu, for Python 3.7, it seems OK, I can see IDLE, Python 3.7, Python 3.7 Module Docs for both 32 and 64 bit. But for Python 2.7, there is only Python 2.7 32-bit in the menu. But I'm able to start Python 2.7 64-bit by running py -2.7-64. It means "py.exe" is able to find my 64-bit Python 2.7 version. – Vespene Gas Nov 15 '18 at 07:37
  • I was thinking of something like this (https://kencenerelli.wordpress.com/2017/11/25/list-installed-programs-on-windows-10/) or even just Apps & Features in Windows Settings. – Patol75 Nov 15 '18 at 07:56

6 Answers6

156

I just got the answer. By typing "py -h" or "py --help" I got the help message:

C:\Users\admin>py -h
Python Launcher for Windows Version 3.7.1150.1013

usage:
py [launcher-args] [python-args] script [script-args]

Launcher arguments:

-2     : Launch the latest Python 2.x version
-3     : Launch the latest Python 3.x version
-X.Y   : Launch the specified Python version
     The above all default to 64 bit if a matching 64 bit python is present.
-X.Y-32: Launch the specified 32bit Python version
-X-32  : Launch the latest 32bit Python X version
-X.Y-64: Launch the specified 64bit Python version
-X-64  : Launch the latest 64bit Python X version
-0  --list       : List the available pythons
-0p --list-paths : List with paths

Which tells me that "-0" (zero, not letter "O") lists the available pythons:

C:\Users\admin>py -0
Installed Pythons found by py Launcher for Windows
 -3.7-64 *
 -3.7-32
 -2.7-64
 -2.7-32

While "-0p" lists not only the versions, but also the paths:

C:\Users\admin>py -0p
Installed Pythons found by py Launcher for Windows
 -3.7-64        C:\Users\admin\AppData\Local\Programs\Python\Python37\python.exe *
 -3.7-32        C:\Users\admin\AppData\Local\Programs\Python\Python37-32\python.exe
 -2.7-64        C:\Python27_64\python.exe
 -2.7-32        C:\Python27_32\python.exe
Vespene Gas
  • 3,210
  • 2
  • 16
  • 27
  • 17
    I guess this requires Python 3.7. With Python 3.6 `py -0` returns `Requested Python version (0) not installed`. – Wollmich Apr 25 '19 at 06:47
  • 1
    I also cannot use the command as it returns `Requested Python version (0) not installed`. – Meysam Sadeghi Nov 22 '19 at 14:35
  • 3
    it shows me the error `command not found: py`, tried with `python -h` which doesn't have `-0` parameter at all. – Ali Abdi Feb 03 '22 at 10:23
  • How does it find these paths? It yielded paths that no longer exist for me. I'm guessing that happens if you delete the folder instead of uninstalling – Mandera Jan 28 '23 at 05:28
9

If py -0p doesn't work for you:

Solution

PowerShell: C:\> dir site.py -s -ErrorAction SilentlyContinue CMD: C:\>dir site.py /s

Citation

I found this workaround on Webucator and made some small adjustments for powershell.

Explanation

dir with the s parameter "lists every occurrence of the specified file name within the specified directory and all subdirectories" (Microsoft Docs).

Since dir <filename> /s returns occurrences of <filename> within the specified directory and all sub-directories, run this from your C drive (unless you only want to check under a specific directory, e.g. check Python installations for a user).

dir site.py /s technically just checks for all site.py files (which is a module in Python's Standard Library) and returns their parent directory's full path. This means that it will miss an installation if site.py has been removed for some reason and also return directories that aren't Python installations but contain python files named site.

Lastly, this returns the parent directory for site.py, not the path for the Python installation's executable (like py -0p would if it worked for you). site.py's parent directory will include the path to the Python installation (e.g. C:\Users\Name\Python36) as well as the additional sub-driectories containing site.py (e.g. \Lib\).

sandeman_13
  • 161
  • 1
  • 6
  • "PS C:\> dir site.py -s -ErrorAction SilentlyContinue" prints nothing on my Windows 10. But this computer has python. "Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32" – H.C.Chen Sep 02 '21 at 03:15
9

In cmd run:

py --list

My result (all versions of python intalled):

 -V:3.11 *        Python 3.11 (64-bit)
 -V:3.9
 -V:3.8           Python 3.8 (64-bit)
 -V:3.6           Python 3.6 (64-bit)
 -V:3.5
 -V:ContinuumAnalytics/Anaconda39-64 Anaconda py39_4.12.0
Ondra Starenko
  • 428
  • 1
  • 6
  • 12
8

if you are using windows type in CMD

where python

and get something like this

C:\Python310\python.exe
C:\Users\facundo\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\facundo\AppData\Local\Programs\Python\Python38\python.exe
parafacundo
  • 93
  • 1
  • 4
1

As I got from running python -2,

Requested Python version (2) not installed, use -0 for available pythons PS C:\Users\ASUS> py -0 Installed Pythons found by C:\Windows\py.exe Launcher for Windows -3.9-64 *

As in, use command py -0

  • This question already has already been answered with similar solution and detailed explanation, so it is not required to be answered again. – Phalgun Sep 05 '21 at 19:10
1

py --list py -0

"Works for me"

rahul raju
  • 11
  • 1