Note

virtualenv is a tool that allow users to create an isolated Python environment. It works by creating a working copy of Python runtime (specified by you) specific to a project without polluting other projects.

Installation

$ pip install virtualenv

Usage

$ mkdir ~/prj/envs; cd ~/prj/envs

# creating virtual env
$ virtualenv myfirstenv  # use -p to specify Python runtime of your choice

# activating env
$ . myfirstvenv/bin/activate

# install other libraries, installation will stay local to the virtual env
$ pip install Flask # e.g. Flask, Django etc...

# deactivate env
$ deactivate

Note

Rather than managing the environments manually. You can use virtualenvwrapper (available via pip) to manage virtual environments.

Usage

# create env
$ mkvirtualenv myfirstenv

# activate env
$ workon myfirstenv

# deactivate env
$ deactivate

# remove env
$ rmvirtualenv myfirstenv

#list all envs
$ lsvirtualenv