Shell script to set up virtualenv and pip Shell script to set up virtualenv and pip python-3.x python-3.x

Shell script to set up virtualenv and pip


As I mean to know you have to activate the virtualenv with:

source activate

I am not sure if this can be done from within a shell script, but you can try it as follows:

virtualenv -q -p /usr/bin/python3.5 $1source $1/bin/activate$1/bin/pip install -r requirements.txt# pip install -r requirements.txt

Excerpt from activate:

$ cat activate# This file must be used with "source bin/activate" *from bash*# you cannot run it directly


Looks like you've found the solution to your problem, but for future reference, you don't need to activate the virtualenv in order to run pip inside it:

#!/bin/bashvirtualenv -q -p /usr/bin/python3.5 $1$1/bin/pip install -r requirements.txt


What was missing was the shebang and I had to start the script using source myscript.sh

#!/bin/bashvirtualenv -q -p /usr/bin/python3.5 $1source $1/bin/activatepip install -r requirements.txt