简体   繁体   English

找不到mkvirtualenv,但是可以执行它

[英]Can't find mkvirtualenv, but can execute it

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. 我正在尝试从bash脚本运行mkvirtualenv ,但一直被告知无法找到它-但是似乎我的系统无法确定是否可以找到它。 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. 避免使用which来检查二进制文件/等。 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 . 更好的选择是typecommand

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. 它们都是内置的,并且都是标准化的(至少在最基本的级别上),并且因为它们是内置的,所以它们也可以看到shell函数和别名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM