I am trying to write a simple script that will help me activate (source) the virtualenv and set some environment variables at the same time. Below is the current version that does not yet have any environment variables.
#!/bin/bash
if [ -z "$BASH_VERSION" ]
then
exec bash "$0" "$@"
fi
# Your script here
script_dir=`dirname $0`
cd $script_dir
/bin/bash -c ". ./django-env/bin/activate; exec /bin/bash -i"
The trouble with this script is two-fold.
When I run it - seemingly successfully as it changes the command line prefix to
(django-env)- it is missing theMy-Computer-Name:in front of it. Obviously, it is an indication of something as I typically have(django-env) My-Computer-Name:as the prefix.It does not activate the virtualenv properly. Namely, when I check
which python, I am notified that the virtualenv Python is used. On the other hand, when I check forwhich piporwhich python3, the global system's Python is used.
What can I do to fix these things and have the environment be activated?
/bin/bash -c, either straight. ./django-env/...orsource ./django-env/... How are you running the script?source script.sh.