Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default Python interpreter on Windows XP

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

like image 516
zjm1126 Avatar asked Jan 12 '11 01:01

zjm1126


3 Answers

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.

like image 162
otherchirps Avatar answered Nov 09 '22 01:11

otherchirps


Make two simple .cmd files:

python25.cmd:

@echo off
set PYTHONHOME=c:\python25
set PATH=%PATH%;c:\python25

python27.cmd:

@echo off
set PYTHONHOME=c:\python27
set PATH=%PATH%;c:\python27

Now you can switch between Python 2.5 and 2.7. :)

like image 38
Igor Pomaranskiy Avatar answered Nov 09 '22 03:11

Igor Pomaranskiy


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

like image 9
John Percival Hackworth Avatar answered Nov 09 '22 02:11

John Percival Hackworth