upstart won't activate my virtualenv for some reason.
This is how I run it
script # My startup script, plain old shell scripting here. cd path/to/env source bin/activate .... end script
the virtualenv runs fine when started manually
Why does this not work?
bin/activate is the bash script being run. One other detail of source will be important. source runs the file provided in your current shell, not in a subshell. Thus it keeps the variables it creates or modifies around after the file is done executing.
Note: Before installing a package, look for the name of your virtual environment within parentheses just before your command prompt. In the example above, the name of the environment is venv . If the name shows up, then you know that your virtual environment is active, and you can install your external dependencies.
So I've worked it out, for some reason upstart doesn't like using 'source' so I changed the line from:
source bin/activate
to
. bin/activate
and that works, don't know why though, so would be interested if someone could explain this
source
is a bash built-in command but only a posix "special" command.
Upstart runs sh -e
when executing the script sections.
sh shell doesn't understand source
, only .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With