I have written a short script to speed up creating, entering, and installing requirements into a virtual environment. The code is below:
#!/bin/bash
red=$(printf '\033[31m')
reset=$(printf '\033[0m')
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate
echo '*' > .venv/.gitignore
if [ -f "requirements.txt" ]
then
pip install -r requirements.txt
fi
echo $red"Virtual Environment Created"$reset
The part giving me problems is the source .venv/bin/activate
line, as it doesn't actually run the activate file in the venv - all the requirements get installed to my local machine directly.
How can I make it switch to the venv?