VirtualenvWrapper on top of Virtualenv

What is Virtualenv?

Virtualenv is a tool for creating isolated Python environments which means you can have separate python environments for your projects.

Lets keep it simple suppose you are working on a project which depends on any python package like Django == 1.6.5. And wow the new version Django == 1.7 is launched with some cool features like migrations etc. You want to start a new project on Django == 1.7 but wait how you are gonna do that?

How to maintain two separate versions of Django.

The answer is simple use Virtualenv to create separate python environments for them. Those two environments will be totally separated from each other as well as from the globally installed packages.

Installing Virtualenv


The easiest way to install virtualenv is to use pip

$ pip install virtualenv

Usage


To create a Virtual environment

$ virtualenv ENV_NAME

Activate the Virtual environment

$ source bin/activate

But wait where is Virtualenv VirtualenvWrapper

Virtualenv Wrapper is the Hero

virtualenvwrapper is the extension to virtualenv. It makes the process of creating and managing virtual environments smoother and easier. It provides a set of commands which helps in managing multiple environments easily and remove conflicts.

Installing Virtualenvwrapper


As usual the best way to install any python package is to use pip.

$ pip install virtualenvwrapper

Some configuration


vi ~/.bashrc

(maybe virtualenvwrapper.sh is in other location, change if necessary)

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

Load file .bashrc

source ~/.bashrc

Creating a Virtual Environment using Virtualenv Wrapper


$ mkvirtualenv env_name

Activating the Virtual environment


$ workon env_name

You can see the changes before the username. This indicates that your virtual environment is activated.

virtualenv

Installing and listing packages using pip


virtualenv

Deactivate Environment


$ deactivate

Great we have come to the end of this post.

virtualenv is a great tool for any python project and virtualenvwrapper makes the process easier. For more details refer to their Official Documentation -

Oh I forget something

$ pip install have-a-great-development
By @Parbhat Puri in
Tags : #python, #virtualenv, #Programming,

Comments !