/usr/bin/env python

Vincent Habchi vince at macports.org
Sun Dec 16 11:39:28 PST 2012


>> 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?
> 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.

Ah, okay. I thought env(1) would look into the environment for a python variable and replace the whole shebang line by the result of the search. So I guess you’re right, I’ll have to replace all occurrences with the python bin selected by the user.

Thanks a lot for the explanations,

More information about the macports-dev mailing list