How to use Python virtualenv

Feb 11, 2014   #python 

First of all, make sure virtualenv is installed. Run the following command:

virtualenv --version

If not installed, use easy_install to install:

 sudo easy_install virtualenv


sudo pip install virtualenv

To use virtualenv, just run the following command in the directory where you want the environemnt to be set up. I usually do this:

mkdir new-project
cd new-project
mkdir .env
virtualenv .env

This sets up the environment.

To use it run:

cd new-project
source .env/bin/activate

The prompt should be changed with a (.env) prefix. Until you execute the deactivate command, the environemnt will use the .env directory for the environment files.

For more info go here: