Install multiple Django version using virtualenvwrapper in ubuntu

Hi guys, Are you finding difficulties to install multiple django version and switch between them easily? Here is the way.

We can achieve this by using virtualenv and virtualenvwrapper. virtualenv allows you  to set up multiple isolated Python environments and virtualenvwrapper allows create and manage multiple virtualenv seamlessly.Here is the simple steps to setup

1) Install virtualenv and virtualenvwrapper

    sudo pip install virtualenv virtualenvwrapper
2) Create virtual env directory 

   mkdir ~/.virtualenvs
3) Set enviromental path in .bashrc file

vi .bashrc, add below lines to end of the file.

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.6
export WORKON_HOME=$HOME/.virtualenvs
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
source /usr/local/bin/virtualenvwrapper.sh

4) Close your terminal and open new one. Create virtual environment

 mkvirtualenv env1

After the above step you see the terminal something like

(env1)shabeer@shabeer-Vostro-1400:~$

Congrates.. Our virutual enviroment is ready and we can now install our Django version under env1,

5) (env1)shabeer@shabeer-Vostro-1400:~$ wgethttp://www.djangoproject.com/download/1.3/tarball/
6) (env1)shabeer@shabeer-Vostro-1400:~$ tar -zxvf Django-1.3.tar.gz
7) (env1)shabeer@shabeer-Vostro-1400:~$ cd Django-1.3
8) (env1)shabeer@shabeer-Vostro-1400:~$ python setup.py install
Above step will install django 1.3 under  virtual enviroment env1, and we can access it only by env1.

9) If you want work on django 1.2.5, create another virtual enviroment

mkvirtualenv env2, after this command and promt will be like this

(env2)shabeer@shabeer-Vostro-1400:~$

10) Download Django 1.2.5 and follow step 6 to 8.

(env2)shabeer@shabeer-Vostro-1400:~$wget http://www.djangoproject.com/download/1.2.5/tarball/

11) If you want to switch to env1 , run below command

(env2)shabeer@shabeer-Vostro-1400:~$ workon env1

Using above command we can easily switch environment.

Done! Thanks.