Change default Python interpreter on Windows XP

2019-03-09 12:30发布

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

7条回答
别忘想泡老子
2楼-- · 2019-03-09 13:01

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.

查看更多
登录 后发表回答