Change default Python interpreter on Windows XP


Question

I have two python versions: Python 2.5 and Python 2.7. When I'm setting up django, I want to use Python 2.7, but django is using Python 2.5 somehow.

How can I make sure that django use Python 2.7? I'm using Windows XP

1
13
10/12/2017 12:48:11 PM

Accepted Answer

Change your PATH system environment variable to point to the version of Python you want to use.

10
1/12/2011 2:22:49 AM

Changing your PATH will help, if you always call python directly, rather than relying on file association.

For example: "python foo.py" will run the 'foo' script with whichever python is first on your PATH.

However, if you just run "foo.py", the handler associated in the registry, for this file extension, will be the first one called.

In your case, it sounds like that would be python 2.5. Have a look by opening regedit, and checking the values of:

HKEY_CLASSES_ROOT\Python.File\shell\open\command

The (default) value listed will probably be something like "C:\Python25\python.exe" "%1" %*

A quick (and dirty?) fix for you would be to change these values to the python version you actually want.

A better fix would be to do something like what's outlined in this feature request:

http://bugs.python.org/issue4485

Since then, as long as you had admin rights, you could switch as you needed by pointing assoc at the version you want quickly.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon