the reason I'm asking about is that Python 2 and 3 are also installed on my computer, and therefore it is ambiguous, since both are executed using the python command.
To run the Python 2 executable:
C:\> py -2
To run the Python 3 executable:
C:\> py -3
where py is a Python launcher that is associated with your Python 3 installation.
py recognizes that shebang (for example, #!/usr/bin/env python3 runs the Python 3 executable), it respects virtualenv (if you run py without specifying an explicit python executable), i.e. do:
C:\> py your_script.py
and the correct version of python is used automatically - you do not need to explicitly specify the version of Python on the command line.
Is there any special reason why Python 3.x is not installed on Windows to run by default with the "python3" command line, as it does on Mac OSX and Linux?
OSX and Linux have the python executable installed by default, as a rule, and in most cases it refers to the Python 2 version, so you need to have a separate python3 name.
By default, there is no Python on Windows. And so any version you installed is just python (I think). The recommended way to manage multiple versions of python is to use the Python launcher.
Is there a way to configure Python to work like this?
If you want to type python3 some_script.py instead of py some_script.py or even just some_script (it is assumed that .py is in %PATHEXT% and the Python launcher is configured to run Python scripts (check out assoc .py and ftype Python.File ) - by default), then create a bat file, for example, python3.cmd and put it in %PATH% :
"C:\path to\Python 3.X\python.exe" %*