RSS Feed

Basic Django setup with VirtualEnv and Pip

August 13, 2011 by Helmut

For a while I struggled to get an ideal setup procedure for new Django projects. On an Ubuntu-based system, this is the process I now follow for each new Django project (I assume MySQL is already installed):

  • 1. Change to your project’s directory
  • 2. Install VirtualEnv
sudo easy_install -U virtualenv
  • 3. Initialize the virtual environment for your project (substitute your own directory for “ve” if you want)
virtualenv --no-site-packages ve/
  • 4. Activate the virtual environment
source ve/bin/activate
  • 5. Install Pip (UPDATE: this is only required if you want to update to the latest version, since Pip is included with VirtualEnv)
easy_install -U pip
  • 6. Install Django
pip install Django
  • 7. Install MySQL bindings for python
pip install MySQL-python
sudo apt-get install libmysqlclient-dev
  • 8. Install Django-South, if you use it
pip install south
  • 9. Create your Django project, application, etc.

I’ve tried different approaches (including Vagrant), but I like this method because it is very simple. How do you go about a new Django setup? Anything that can be improved?

UPDATE: Thanks to Doug Warren for some pointers on what to improve. Further changes coming soon.


  • http://www.facebook.com/doug.warren Doug Warren

    Why install pip?  It comes with virtualenv.

    Why sudo on the easy_install to install pip?  You’re pointing at the virtualenv already therefore it should be done as the local user.

    Consider using a requirements.txt file that could just contain:
    Django
    MySQL-python
    South

    then you can run pip install -r requirements.txt and have it all done.

    I did a similiar blog post a few weeks ago about a Django project at http://dougwarren.org/2011/07/amazon-android-app-store-free-app-of-the-day-rss-feed-in-django/ That included the initial set up, git, and WSGI.

  • http://www.facebook.com/doug.warren Doug Warren

    Why install pip?  It comes with virtualenv.

    Why sudo on the easy_install to install pip?  You’re pointing at the virtualenv already therefore it should be done as the local user.

    Consider using a requirements.txt file that could just contain:
    Django
    MySQL-python
    South

    then you can run pip install -r requirements.txt and have it all done.

    I did a similiar blog post a few weeks ago about a Django project at http://dougwarren.org/2011/07/amazon-android-app-store-free-app-of-the-day-rss-feed-in-django/ That included the initial set up, git, and WSGI.

    • Helmut

      Thanks for the help! I’ll integrate your tips into my post soon. :)

      I’m still relatively inexperienced with Django, so any advice is much appreciated. Thanks!