I want to activate a virtual env in shell script, so I write a simple script as follow:
#!/bin/bash
source ~/env/lib/bin/activate
#nohup python mock_run.py
#echo $! > save_pid.txt
I start the script with sh start.sh
, but I got error as follow:
start.sh: 3: start.sh: source: not found
I run source ~/env/lib/bin/activate
is ok, so why can not in shell script?
sh start.sh
. Also source has an alias.
so try. ~/env/lib/bin/activate
#!/bin/bash
in my script, and. ~/env/lib/bin/activate
is ok, but whysource
is not ok?sh start.sh
. Run the script with./start.sh
. Don't explicitly invoke the shell.