【发布时间】:2015-03-27 05:39:04
【问题描述】:
我正在尝试在 Mac(小牛队)上自动删除和重新创建 virtualenv。
我有一个文件clean_venv.sh:
#!/bin/bash
echo "Start"
deactivate
rmvirtualenv test
mkvirtualenv test
这给出了:
Start
./clean_venv.sh: line 3: deactivate: command not found
./clean_venv.sh: line 4: rmvirtualenv: command not found
./clean_venv.sh: line 5: mkvirtualenv: command not found
但是,在同一位置运行命令可以正常工作。为什么是这样?
【问题讨论】:
-
你的标题写着
sh,但标签和问题写着bash。这是两个不同的外壳。 Bash 与股票 Bourne shell 向上兼容,但它们是不同的;即使/bin/sh是 Bash 的符号链接,它也会导致 Bash 在 POSIX 兼容模式下运行,从而以多种方式改变其行为。 -
我的意思是
.sh- 为了清楚起见,我修改了标题。不过,也许是一种更好的表达方式。另外,我找到了一个解决方法,我已发布为答案