Wednesday, June 13, 2012

Quick guide to setting up virtualenv

UPDATE: I just learned about virtualenv-burrito which installs virtualenv along with virtualenvwrapper which provides neat wrapper functions to work smoothly with virtualenv.

So here's how you go about installing virtualenv burrito:

If you do not already have curl installed:
$ sudo apt-get install curl

Next, follow these simple instructions:
$ sudo curl -s | $SHELL

And when you're done do..
$ source /home/<<username>>/.venvburrito/  [You will have to run this command each time you start a new terminal]
Replace <<username>> with your relevant username..

Now to make your first virtualenv,
$ mkvirtualenv <<name>>

to use it..
$ workon <<name>>

The directories for this virtualenv are available at

to quit a virtual env
$ deactivate

Here's a good guide on the same:
1. $ sudo easy_install virtualenv
2. Navigate to/create a folder where you want to store your virtual environment project.
3. $ virtualenv --no-site-packages projectname
You're done.
To start using your venv..
4. $ cd projectname
5. $ source bin/activate
6. Install dependencies from requirements.txt using this tutorial. Note: You do not need mysql. [Here's a requirements.txt dated 06/13/2012 to use.]
7. To quit..  $ deactivate
8. Make sure you use easy_install to install packages as opposed to pip because I noticed that pip does not always install to the venv directory, rather it goes to the usr/local/lib/ directory.

To setup Eclipse to run your django venv
1. Change Eclipse's Python interpreter by..
- Eclipse > Window > Preferences > Interpreter - Python > New...
- Navigate to /path/to/venv/projectname/bin/python . Hit OK.
- Scroll down and make sure you also check the following folders (which may be unchecked) at the "Selection needed" screen..
These may be named differently on your system. If you do not check these and if you get an error "Python stdlib not found...." make sure you DO check these folders too!
2. Remove any other interpreters just in case.
3. Hit Apply. Then Hit Ok.
4. Inside the Debug Configuration just make sure that the Interpreter is pointing to the new interpreter you just created.



  1. Great post Keith, everything worked for me!!

    Thank you

  2. I like your blog, I read this blog please update more content on python, further check it once at python online training


Popular Posts