|Ned Batchelder : Blog | Code | Text | Site|
Switching python versions on windows
» Home : Blog : October 2008
I forget what software first set up these associations, but I have .py files registered with Windows so that they can execute directly. The registry defines .py as a Python.File, which has a shell open command of:
"C:\Python24\python.exe" "%1" %*
My PATHEXT environment variable includes .py, so the command prompt will attempt to execute .py files, using the registry associations to find the executable.
But: I wanted to switch from Python 2.4 to Python 2.5. That meant updating the registry in a handful of places. A Python script to the rescue!
""" Change the .py file extension to point to a different
Invoke this with your desired Python installation directory, and the registry is updated to point to it.
Note that this doesn't affect what the command "python" means, that's determined by your PATH enviroment variable. These registry settings change which Python executable is found when you invoke a .py file as a command.