I'm trying to run mkvirtualenv
from a bash script, and I'm keep being told that it can't be found - yet it seems that my system can't make up it's mind about whether or not it can find it. Can anyone explain why I can execute it from the terminal, but not from a script?
jimbo@wavefront:~$ locate mkvirtualenv
jimbo@wavefront:~$ which mkvirtualenv
jimbo@wavefront:~$ mkvirtualenv --version
13.1.2
jimbo@wavefront:~$
It's because it's a function attached to the shell. Run this to see it:
$ type mkvirtualenv
Avoid using which
to check for binaries/etc. It isn't standardized, isn't always available and is an external binary itself (and so is more expensive than the better choices).
The better choices are type
and command
.
They are both built-ins, both standardized (at least at their most basic levels) and, because they are built-in, can see shell functions and aliases too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.