passing an option to the python interpreter

Jabba Laci jabba.laci at
Sat Feb 15 23:32:53 CET 2014


The first line in my scripts looks like this:

#!/usr/bin/env python

I would like to use unbuffered output in a script, which can be done
with the -u option, thus I tried this:

#!/usr/bin/env python -u

But if I want to run it from the command line ($ ./, I
get this error:

/usr/bin/env: python -u: No such file or directory

env is looking for "python -u" but such a command doesn't exist.

How to overcome this problem? I could write

#!/usr/bin/python -u

but I prefer to call python through env. For instance if I put this
last one in a virtualenv, that would call the system-wide interpreter
not the one in the virtualenv.



More information about the Python-list mailing list