[英]virtualenv not active when run from a shell script
When I run source venv/bin/activate
in command line , it activates the virtualenv. 当我在命令行中运行
source venv/bin/activate
时,它会激活virtualenv。 However when run this via a shell script ./run.sh
, I don't see the virtualenv being activated. 但是,当通过shell脚本
./run.sh
运行它时,我看不到virtualenv被激活。 Similar scripts used to work for me in the past , however I am not sure what I am missing now. 过去曾经为我工作过类似的脚本,但是我不确定现在缺少什么。 I am running this is on a mac.
我正在Mac上运行它。
#! /bin/bash
source venv/bin/activate
(venv) 8c859072374671e:my-project tee78$
When you are running source
inside a script. 当您在脚本中运行
source
。 It is running in a new environment. 它正在新环境中运行。 It won't get reflected in the parent shell.
它不会反映在父外壳中。
$ cat run.sh
#! /bin/bash
source venv/bin/activate
It you need that to happen do, source
your script, 它,你需要这样的事情发生呢,
source
脚本,
source run.sh
Also, you won't need the shebang
line :) 另外,您不需要
shebang
行:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.