Change default Python interpreter on Windows XP

后端 未结 7 1205
无人及你
无人及你 2021-02-01 09:06

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 sur

7条回答
  •  醉酒成梦
    2021-02-01 09:19

    If you want to switch between Python 2.x and Python 3.x then easiest way is to use Python Launcher which is included since 3.3 version. This is basically py.exe in Windows folder. To start Python 3.x command prompt, just type

    py -3
    

    To execute script with Python 3.x, use

    py -3 script.py
    

    If you don't specify -3 then 2.x version is used by default. You can also make this explicit by using -2.7 switch.

    py -2.7 script.py
    

    Finally, you can now embed the version number to use in .script file itself. This works because after Python 3.3+ is installed, it associated py.exe with .py files.

    #! python3
    import sys
    sys.stdout.write("hello from Python %s\n" % (sys.version,))
    

提交回复
热议问题