1

How do I set permanent paths for both Python 2 and 3 in command prompt such that I can invoke either every time I open the command window ie 'python2' for python 2 interpreter or 'python3' for python 3 interpreter

jfs
  • 399,953
  • 195
  • 994
  • 1,670

2 Answers2

2

Just use python launcher: py -2 runs Python 2 and py -3 runs Python 3.

If you add #! python3 (shebang) at the top of your script then py your_script.py will use Python 3, if you add #! python2 then it will use Python 2 automatically.

You can also configure it to run all *.py files by default.

jfs
  • 399,953
  • 195
  • 994
  • 1,670
0

Create a python2.bat and a python3.bat file somewhere on your path (could in your main python folder). That file only contains the location of the relavant python.exe, e.g.

C:\Programs\Python26\python.exe %*

Gerard
  • 124
  • 1
  • 4