I have to activate the virtual environment (venv) so I running these commands manually in terminal:
source .venv/bin/activate # To activate the virtual env.
and
deactivate # To deactivate the virtual env
This works fine when running manually. Now I have to insert these commands in a bash script to make AWS CodeDeploy to deploy it on a Ubuntu 18.04 server.
My bash script named after_install.sh looks like this...
#!/usr/bin/env bash
set -e
source .venv/bin/activate
DO SOME STUFF
deactivate
For local testing, I made the script executable and ran the script using bash after_install.sh. But nothing happened. It doesn't activate the virtual environment. It seems none of the above commands worked while running the bash script.
I am not getting why these commands work when I run them manually but not with a bash script. What is going on? I need to write these commands inside the bash script so that AWS CodeDeploy can deploy it on the server.