views:

156

answers:

2

Since I have Django 1.1x on my Debian setup - how can I use virtualenv or similar and not have it mess up my system's default django version which in turn would break all my sites?

Detailed instructions or a great tutorial link would very much be appreciated - please don't offer vague advice since I'm still a noob.

Currently I store all my django projects in ~/django-sites and I am using Apache2 + mod_wsgi to deploy.

+1  A: 

If you have easy_install, or better yet pip installed, should be as easy as:

  1. easy_install/pip install virtualenv
  2. mkdir django1.2
  3. virtualenv django1.2

This will put the python binary in a bin folder inside the django1.2 folder. Just use that python binary, and you've got a nice little self-contained environment. You can then install easy_install/pip into that environment, and then install django 1.2 as well, and hack away.

Bryan Ross
Thanks. Can you provide absolute paths of where you would typically install these? `~/`?
meder
well, usually what I do is this:1. `sudo python -c "$(curl -s http://peak.telecommunity.com/dist/ez_setup.py)"`2. sudo easy_install pip3. sudo pip install virtualenvThen you have `virtualenv` in your path. Proceed from there. You can put the virtual environment anywhere on your filesystem.
Bryan Ross
I know you can put it anywhere, but for example if you have `DocumentRoot` in your apache2 pointing to /var/www/html by default that's probably not a good place.
meder
You don't have to put it in there. You can put it wherever you want, and then just use an `Alias` directive in your httpd.conf to serve the django app in a subfolder. That's how I do it.
Bryan Ross
+1  A: 

Since you are using mod_wsgi, make sure you read:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

Graham Dumpleton