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,
python2should run some version of the Python 2 interpreter, andpython3should run some version of the Python 3 interpreter.- If the
pythoncommand is installed, it is expected to invoke either the same version of Python as thepython3command or as thepython2command.- When a virtual environment (created by the PEP 405
venvpackage or a similar tool such asvirtualenvorconda) is active, thepythoncommand should refer to the virtual environment’s interpreter and should always be available. Thepython3orpython2command (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 aspython2, unless the user deliberately overrides this or a virtual environment is active.