Reputation: 13254
Suppose you write a Python shell script. It will probably start with something like this:
#!/usr/bin/python
The problem is, if you often work with virtualenv
this call is just plain wrong. You actually would like this script to call virtualenv's python binary, if it is in this environment and /usr/bin/python/
otherwise. Just like your shell would decide, when you write python
as a shell command.
How would you write your #!
line to fulfil this requirement?
Upvotes: 1
Views: 82
Reputation: 1122412
Use #!/usr/bin/env python
instead.
The env
command looks up binaries in the current PATH
; activating your virtual environment adds your virtualenv bin/
directory to the path and env
will find your python binary there instead of the global python.
Upvotes: 6