VirtualEnv, put simply, is an isolated working copy of Python which
allows you to work on a specific project without worry of affecting other projects

It enables multiple side-by-side installations of Python, one for each project.

It doesn’t actually install separate copies of Python, but it does provide a
clever way to keep different project environments isolated.

Installing VirtualEnv (CentOS):

Install a selection of development tools:

yum -y groupinstall "Development tools"
yum -y install zlib-devel  # gen'l reqs
yum -y install bzip2-devel openssl-devel ncurses-devel  # gen'l reqs
yum -y install mysql-devel  # req'd to use MySQL with python ('mysql-python' package)
yum -y install libxml2-devel libxslt-devel  # req'd by python package 'lxml'
yum -y install unixODBC-devel  # req'd by python package 'pyodbc'
yum -y install sqlite sqlite-devel  # you will be sad if you don't install this before compiling python, and later need it.

Install Python 2.7.4

tar xf Python-2.7.4.tar.bz2 
cd Python-2.7.4
./configure --prefix=/opt/python2.7
make && make altinstall

Install distribute

tar xf distribute-0.6.27.tar.gz 
cd distribute-0.6.27
python2.7 install

Install/Configure virtualenv and virtualenvwrapper

tar -xvzf virtualenv-1.9.1.tar.gz 
python virtualenv-1.9.1/ install
tar -xvzf virtualenvwrapper-*
python virtualenvwrapper-4.0/ install
echo 'export WORKON_HOME=~/Envs' >> .bashrc # Change this directory if you don't like it
. $HOME/.bashrc
mkdir -p $WORKON_HOME
echo '. /usr/bin/' >> .bashrc
. $HOME/.bashrc

You can now run commands like:

mkvirtualenv foo --python2.7

This will give you a clean python2.7 environment to work on.

  • No labels