0

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.

3
  • why don't you reinstall python 2.7.12 ? Commented Dec 31, 2016 at 23:38
  • 2
    In the new launcher that's distributed with 3.6, running py.exe on the command line now runs the highest version of Python 3.x that's installed. To run Python 2 instead, use py -2. To make this the default, set the environment variable PY_PYTHON=2. Commented Dec 31, 2016 at 23:39
  • 1
    using a package manager like Anaconda can simplify the process of switching versions or using multiple versions on your computer. you can read more HERE Commented Dec 31, 2016 at 23:42

1 Answer 1

5

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
Sign up to request clarification or add additional context in comments.

1 Comment

Note that if you're using the old, pre-3.6 version of the launcher, it defaults to running the highest version of Python 2, if installed, and otherwise the highest version of Python 3. This was changed in 3.6 to prefer Python 3. However, for virtual shebangs in scripts, such as #!python and #!/usr/bin/python, the new version of the launcher still maps "python" to Python 2 for the sake of Unix compatibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.