so while playing with some aliases I realized that there are three python commands (without taking into account the python 3 commands) in the terminal:
So my question is why is this the case? Why do we need three? I understand the need to have a generic one (python) and the need to have another one to distinguish python3 from python2 but the rest I do not know.
Furthermore, how can I see if they are linked to the same file (symbolic link)?
python
is the default interpreter used by the distribution. It may (or may not1) point to python3 in the future.
python2
is the default Python 2 interpreter (that is the same as above if python
points to python2
, not otherwise). It points to the current stable/supported interpreter.
python2.7
is the specific interpreter --- you can have for example python2.7
as the current one, and a python2.1
that you need to check compatibility matters.
To see all of them:
[romano:~] % ls -l /usr/bin/python /usr/bin/python2 /usr/bin/python2.7
lrwxrwxrwx 1 root root 9 jul 22 2014 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root 9 jul 22 2014 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3345416 jun 22 20:51 /usr/bin/python2.7
So in your scripts — in the shebang2 — you use python
if you want to use the default interpreter for the distribution (and if you want total future safety you have your script both working in version 2 and 3, but see note 1 below); python2
or python3
if you need version 2 or 3 specifically, but it's ok using the default one the distribution offers (recommended); python2.7
if you need that specific version and you prefer that your script fails if it's not available.
1 I think it will never change to point to python3
, it's too dangerous. But well, I have no crystal balls...
2 this is the first line of the executable scripts that for Python should look like
#! /usr/bin/env python2
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments