create virtualenv with virtualenvwrapper code example

Example 1: how to use virtualenvwrapper

# install Virtual Environment alternative to virtualenv
pip install virtualenvwrapper

# modify your .profile file
# find out where virtualenvwrapper.sh file is by issuing which command
# source it as shown below
source /usr/local/bin/virtualenvwrapper.sh

# setup an environment
mkvirtualenv dev_env1
mkvirtualenv dev_env2
mkvirtualenv dev_env3
mkvirtualenv dev_env4

# create list of your projects, project1...projectN
mkproject project1
mkproject -p python3 project2  # this project is for python 3 only
mkproject project3
mkproject projectN

# go to the folder where you have cloned an existing repo
# and run the command to bind that project to this environment
setvirtualenvproject

# get list of all environments
workon

# choose a project to work on based on previous output
# say you have dev_env1, dev_env2, dev_env3... dev_envN
# state the name of the project to work on 
workon dev_env1

# other tasks
# remove un-needed environments
rmvirtualenv dev_env4

# build a temp environment if needed
mktempenv

# .profile needs this variables set for export
# i.e. export WORKON_HOME="/home/rajib2k5/envs"
#      export PROJECT_HOME="/home/rajib2k5/dev"

# in order to leave an environment, run the command below 
deactivate

Example 2: activate environment in virtualenvwrapper

workon [<name>]