The “python” command and associated interpreter versions

PEP 394 – The “python” Command on Unix-Like Systems lays out the official recommendations for which Python interpreter version should be used when calling a command like “python”.

The most important points are the following:

  • When invoked, python2 should run some version of the Python 2 interpreter, and python3 should run some version of the Python 3 interpreter.
  • If the python command is installed, it is expected to invoke either the same version of Python as the python3 command or as the python2 command.
  • When a virtual environment (created by the PEP 405 venv package or a similar tool such as virtualenv or conda) is active, the python command should refer to the virtual environment’s interpreter and should always be available. The python3 or python2 command (according to the environment’s interpreter version) should also be available.

Note that the second bullet point was changed in 2019. Prior to that date, it said:

  • for the time being, all distributions should ensure that python, if installed, refers to the same target as python2, unless the user deliberately overrides this or a virtual environment is active.