The shebang line in any script determines the script’s ability to be executed like a standalone executable without typing
python beforehand in the terminal or when double clicking it in a file manager (when configured properly). It isn’t necessary but generally put there so when someone sees the file opened in an editor, they immediately know what they’re looking at. However, which shebang line you use is important.
Correct usage for (defaults to version 3.latest) Python 3 scripts is:
Correct usage for (defaults to version 2.latest) Python 2 scripts is:
The following should not be used (except for the rare case that you are writing code which is compatible with both Python 2.x and 3.x):
The reason for these recommendations, given in PEP 394, is that
python can refer either to
python3 on different systems.
Also, do not use:
“python may be installed at /usr/bin/python or /bin/python in those
cases, the above #! will fail.”