When I run source venv/bin/activate
in command line , it activates the virtualenv. However when run this via a shell script ./run.sh
, I don't see the virtualenv being activated. 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.
#! /bin/bash
source venv/bin/activate
(venv) 8c859072374671e:my-project tee78$
When you are running source
inside a script. 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 run.sh
Also, you won't need the shebang
line :)
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.