virtualenvwrapper setup

virtualenvwrapper is a handy tool, used to manage virtualenvs.

virtualenvs are individual sandboxes that contain an isolated python installation and environment. You should always use a different virtualenv for every different python project that you have. virtualenvwrapper helps exactly with that.

Here's how to set it up

# Make sure you have an up-to-date version of pip.
pip install --upgrade pip

# Download virtualenv and virtualenvwrapper with pip.
pip install virtualenv virtualenvwrapper

# Set this variable to a suitable default.
export WORKON_HOME=$HOME/.virtualenvs

# Source virtualenvwrapper.sh.
# This step depends on your python installation.
# If you installed python with HomeBrew, then use the following path:
source /usr/local/bin/virtualenvwrapper.sh

You will likely want to add the last two commands to your shell init file (for example, .bashrc).

Working with virtualenvwrapper

  • To create a new virtualenv: mkvirtualenv <name>
  • To list all existing virtualenvs: lsvirtualenv
  • To activate it: workon <name>
  • To deactivate it: deactivate
  • To destroy it: rmvirtualenv <name>

Reference: http://exponential.io/blog/2015/02/10/install-virtualenv-and-virtualenvwrapper-on-mac-os-x/

Comments

Comments powered by Disqus