Once you start doing any serious python development, you start running into name conflicts. Having two modules named the same creates all sort of import problems. In order to avoid them, python has what is called a virtualenv. Packages installed within a virtualenv are only accessible to the virtualenv.
Assuming you follow our pip article, you now know about pip and the proper way to install packages in python.
$ sudo pip install virtualenv
Using and managing virtualenvs can become a headache. In order to alliviate this, virtualenvwrapper was written. Virtualenvwrapper is a wrapper around virtualenv that provides some nice utilities.
Installation is one step harder than just installing virtualenv, because it involves editing your ~/.bashrc file. This file needs to be edited in order for the virtualenvwarpper to just work everytime you boot your computer witout having to source your file many times.
$ sudo pip install virtualenvwrapper
#cd into your home direcotry.
$ cd ~
#create a folder that will contain all of your virtualenvs. This is commonly named .virtualenvs
$ mkdir .virtualenvs
#edit your .bashrc file
$ echo source /usr/local/bin/virtualenvwrapper.sh >> ~/.bashrc
#source the .bashrc file(assuming you are working from your home directory).
$ source .bashrc
Let's explore some of the utilities that virtualenv has.
#to create a new virtualenv. This command will install a new enviroment which will contain all of the packages installed in your main python path.
$ mkvirtualenv myenv
#If you want a new enviroment without any extar packages, you can use the option --no-site-packages.
$ mkvirtualenv myenv --no-site-packages
#To delete an enviroment.
$ mrmvirtualenv myenv
#To show a list of the available envioroments.
#To activate an specific enviroment.
$ workon myenv
This conclude our introduction to virtualenv and virtualenvwrapper. In later articles I will be talking about postactiavte, activate, predeactivate scripts.