Last Updated: February 25, 2016
·
640
· shrayas

Quickly activate a virtualenv

It really is a pain to type source env/bin/activate every single time to activate a python virtualenv so i just cooked up a simple function that i add to my shell that does it for me

Note: I always create my virtualenv in a folder called env so that is hardcoded in there. It has to be changed as required

function a()
{
  if [ -d "env" ]
    then
      source env/bin/activate
  else
    echo "Directory doesn't contain a virtualenv"
      fi
}