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, andpython3
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 thepython3
command or as thepython2
command.- When a virtual environment (created by the PEP 405
venv
package or a similar tool such asvirtualenv
orconda
) is active, thepython
command should refer to the virtual environment’s interpreter and should always be available. Thepython3
orpython2
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 aspython2
, unless the user deliberately overrides this or a virtual environment is active.