The importance of env (and how it works with virtualenv)
18th of September 2008
I have for a long time wondered why I'm supposed to use this in the top of my executable python files:
#!/usr/bin/env python
Today I figured out why.
The alternative, which you see a lot around is something like this:
#!/usr/bin/python
Here's why it's better to use env rather than the direct path to the executable: virtualenv. Perhaps there are plenty of other reasons the Linux experts can teach me but this is now my first obvious benefit of doing it the way I'm supposed to do it.
If you create a virtualenv, enter it and activate it so that writing:
$ python
starts the python executable of the virtual environment, then this will be respected if you use the env shebang header. Good to know.