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
To install a Python version that is not listed there run py install followed by the version number, e.g. py install 3.14
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
To install a Python version that is not listed there run py install followed by the version number, e.g. py install 3.14
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
Managing multiple python versions on Windows
How to list down all available python versions in my windows - Stack Overflow
windows - How to list all Python versions installed in the system? - Stack Overflow
Which version of Python do I have installed? - Stack Overflow
Videos
I've coded a bit in Python for years, and had an existing installation of 3.10.7 which I installed using Chocolatey some time ago.
Then I thought I would play with WhisperX. The tutorial I found walked me through installing Anaconda, which I did not realize would install a second copy of Python, this time 3.12. It broke a couple of existing projects, and so I gave up on WhisperX and swapped the PATH variable back to the 3.10 installation.
Then, last week, I read about Gemma3 and thought I might experiment with that. I found a blog post -- can you see where this is going? -- that pointed me to Ollama. Which I installed, once again not realizing it would install yet another copy of Python, this time 3.13. It didn't break my projects this time, but I think that's because the user-level PATH variable is still pointing at 3.10 while the system-level PATH variable is pointing at 3.13. Oh, and I never got Gemma3 up and running, possibly because it doesn't like 3.10.
So now I have three copies of Python installed, they're fighting with one another over the PATH variable, and I still haven't gotten to experiment with local AI stuff. There's got to be a better way to manage these things.
My googling so far has pointed me at pyenv, which as far as I can tell is a Linux-only utility. I think. I love me some Linux, but the machine in question is a Windows box. Is there some obvious utility I should be using for swapping back and forth between versions that I'm just not finding?
Use py -0 to find all installed versions of python on your PC.
Wallbloggerbeing explained how to change your default.
Advanced System Settings > Advance (tab) . On the bottom you'll find 'Environment Variables'
Double-click on the Path . You'll see path to one of the python installations, change that to path of your desired version.
I'm writing a Python IDE and I want to let user to choose the interpreter for executing the program.
Just do it like other IDEs then and simply supply a dialog where users can add interpreters they want to be able to run the code with.
Eclipse does this for example for Java Runtimes, and it’s perfectly fine to have it like that. Especially for languages like Python where virtual environments are an important thing which each have their own exectutable.
You certainly can come up with a one-time detection that checks some common locations. For Windows, this would obviously be the registry, as the py.exe launcher requires the interpreters to be registered there—at least the system-wide ones. On Unix machines, you could check the common bin/ folders, most prominently /usr/local/bin/ which is the standard location where Python installs itself. You could also check the PATH for Python executables. But all those things should be considered carefully and only offer an initial setup. There are always edge cases where a user didn’t do the “standard thing” where your detection will fail. For example I don’t have my Python interpreters in my path, and a linux server I access I have installed Python into a non-standard folder in my home directory. And finally, just because it looks like Python doesn’t mean it is Python.
Yes, you can do some guesswork to come up with an initial set of interpreters, but really don’t spend too much time on it. In the end, you won’t be able to detect everything perfectly anyway. And you will miss virtual environments—which might be very crucial to the project the user is working on in your IDE.
So instead of wasting time on bad detection, spend more time on creating a manual dialog to register interpreters. You will need that anyway, and a good interface can make it very easy—even for beginners—to use it.
Not sure this is entirely possible, but here's a dirty fix:
from subprocess import *
from time import sleep
for i in range(2, 4):
x = Popen('python' + str(i) + ' --version', shell=True, stdout=PIPE, stdin=PIPE, stderr=STDOUT)
while x.poll() == None:
sleep(0.025)
print('Exit code of ' + str(i) + ' is:',x.poll())
x.stdout.close()
x.stdin.close()
The exit code will tell you if Python2 or Python3 is installed. You could add a second iterator for python versions 2.4, 2.4, 3.1, 3.2 etc etc. Or just keep them in a list, whichever you prefer for this already dirty fix.
To check the version of one's Python's Software version, one should use the following code in command prompt:
python -V
Reference: http://docs.python.org/using/cmdline.html#generic-options
In a Python IDE, just copy and paste in the following code and run it (the version will come up in the output area):
import sys
print(sys.version)