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)[email protected]:~$
    Congrates.. Our virutual enviroment is ready and we can now install our Django version under env1,
  5. To install django 1.6
    pip install django==1.6
  6. If you want to work on django 1.4, create another virtual enviroment
    mkvirtualenv env2
    after this command and promt will be like this
    (env2)[email protected]:~$
  7. Then install django 1.4
    pip install django==1.4
  8. If you want to switch to env1
    workon env1
  9. If having any trouble with module not found errors, you might have to try enabling the global site-packages by the below command
    toggleglobalsitepackages

Done! Thanks.


comments powered by Disqus