/usr/bin/env python

Joshua Root jmr at macports.org
Sun Dec 16 05:10:22 PST 2012


On 2012-12-16 19:46 , vincent habchi wrote:
> Folks,
> 
> Some scripts of a port I’m trying to set up use #!/usr/bin/env python, which seem to always point to Apple’s python. Which environment variable have I to change so that ‘env’ will return a MacPorts python instead?

There is no environment variable that will help here; 'python' is not
guaranteed to be present in ${prefix}/bin.

The reason /usr/bin/env is used in the shebang line here is that the
interpreter for a script must be an absolute path, but the author
doesn't know where python will be on the user's system. The env command
is for altering the environment, but is used without setting any
variables, and is thus a noop that gets around the absolute path
requirement. Only PATH has any effect on which python is found.

Usually you would run a reinplace on the scripts in this situation.

- Josh


More information about the macports-dev mailing list