Python Script Hashplings

Matthew Lefavor mclefavor at
Fri Jul 26 16:58:24 CEST 2013

> Thanks Matthew Lefavor! But specifically, why use "#!/usr/bin/env python3"
> instead of "#!/usr/bin/python3"?

The "env" program looks up its argument in the current $PATH environment
variable, and then executes that. This means you aren't necessarily tied to
/usr/bin/python3. It makes things more portable.

For example, old Linux distributions don't have Python 3 installed with
them, and the user might not have permissions to install Python 3
system-wide. Instead they have it in some sort of ~/HOME/bin directory, and
then that is placed on the path by their .bashrc file. If your shebang line
was "#!/usr/bin/python3", the program wouldn't work without them changing
that line. If the shebang ling was "#!/usr/bin/env python3", it would find
the Python3 binary no problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list