Reasons to use virtualenv

  • Allows different applications to use different versions of libraries
  • Allows applications to be unaffected by changes to the globally installed libraries
  • Obviates need for access to common directories like site-packages, to which you might not have access


$ sudo pip install virtualenv

Creating a virtualenv

Create a virtualenv in its own directory with virtualenv ENV_DIR.

  • You can choose the python executable with -p PYTHON_EXE or --python=PYTHON_EXE
  • You can optionally use the global shared libraries with --system-site-packages

To start using

Run source bin/activate to set the $PATH environment variable and change the prompt
Use pip install to install any packages you need

To leave a virtualenv

Run deactivate from anywhere to reverse these changes

Deleting a virtualenv

Delete it by deleting the directory.