0 votes
1 view
in Python by (32.3k points)

Should I put the shebang in my Python scripts? In what form?

#!/usr/bin/env python

or

#!/usr/local/bin/python

Are these equally portable? Which form is used most?

1 Answer

0 votes
by (76.5k points)
edited by

To define the ability of the script shebang line is used and 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.

The Correct usage for Python 3 scripts is as follows:-

#!/usr/bin/env python3

To know more about this you can have a look at the following video tutorial:-

...