Cannot Use Python 2 from Command Line

3.8k Views Asked by At

I recently tried to uninstall Python 3.5.2 and installed Python 3.6.0. I used to use python in the command line to run Python 3.5.2 from the command line, and py to run Python 2.7.12. Now, python runs Python 3.5.2, and py runs Python 3.6.0. I am running Windows 10, and python3, python2, py2, and py3 do not do anything.

1

There are 1 best solutions below

1
Mark Tolonen On BEST ANSWER

Don't bother adding Python to the path. Just use:

py            Run highest version of Python (override with PY_PTYHON environment variable).
py -2         Run highest version of Python 2.
py -3         Run highest verssion of Python 3.
py -2.7       Run Python 2.7.
py -2.7-32    Run python 2.7 32-bit when on a 64-bit system.

More: https://docs.python.org/3.6/using/windows.html#python-launcher-for-windows

Note you can also specify in scripts which version to use as well with, for example:

#!python2
#!python3
#!python2.7