Aug 10, 2015

Flash fast virtual environment activation

When working with virtual environments in python (which is always!) I create an alias for each venv I have:

# Please replace "project" with your project's name!
alias project="cd /path/to/project && source activate && cd project"

With this, activating and entering my project is as simple as:

$ project

You can't possibly beat that!

Note 1: Assuming this folder structure:

|- /path/to/project
   |- activate <--- Your own personal activator
   |- venv
      |- ...
      |- bin
         |- ...
         |- activate <--- Original
   |- project
      |- ...

Note 2: I use my own activate file as per -multi environment- Django settings. If you use the default one, your alias would be:

# Please replace "project" with your project's name!
alias project="cd /path/to/project && source venv/bin/activate && cd project"

Comments