Virtualenv and source version control

You generate a "requirements" file (usually requirements.txt) that you commit with your project:

pip freeze > requirements.txt

Then, each developer will set up their own virtualenv and run:

pip install -r requirements.txt

All these environment hassles are kind of common when you are doing python/django development! I went through all these problem, and I have tested some solutions! Things that I have tested:

  1. Project running local
  2. Project running in virtualenv
  3. Project running in a VM
  4. Project running in a VM, using vagrant

The best solution I found was #4! because the company that I used to work, each person in the team has a different OS, all sort of windows, mac and linux, and to install all dependencies for each environment it takes time! So we decided to try virtualenv, which is really good! but still each person has to setup his own enviroument. The problem in virtualenv is that all python sources are within the environment that u create! So I would not push those files to a source version control! Best solution was #4, because that was exactly what I needed, Vagrant uses Chef to setup your environment, so you just have to write some recipes, and let vagrant run them for u! Then u push those recipes to SCM, then when the next person get the files from SCM and reloads the VM all dependencies will be automatically install!

I have a blog post explaining more about the subject as well as I have created a Django Blank project in github so you can get that to have a start point of your project using vagrant.

http://arthurnn.com/blog/2011/11/25/easy-django-quickstart/ (link no longer active, so linked to Wayback Machine)

EDIT

Solution from Chris Pratt is a good one as well, however some libraries are not so straightforward to install in all OS, for instance, a lot people on Mac get problems when they want to install MySQLdb-python. which is a really common library, but if everyone in your team has to spend time solving this issues, is not good at all!