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, and
python3should 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 the
python3command or as the
- When a virtual environment (created by the PEP 405
venvpackage or a similar tool such as
conda) is active, the
pythoncommand should refer to the virtual environment’s interpreter and should always be available. The
python2command (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.