All I want to do is. . .
. . .use virtualenv + virtualenvwrapper with Python.
Description: Virtualenv allows you to make isolated working copies of Python so that you can work on a specific project without affecting other projects. Virtualenvwrapper provides commands that make it simple to create and manage your virtual environments.
Contributors:
sloria
Updated: 07/14/13
Do these first:
-
Install Python 2 and/or 3
# On Mac >= 10.5 with homebrew $ brew update ## Install Python 2 $ brew install python ## Install Python 3 $ brew install python3 ## Follow any instructions that appear after each brew install
# Is everything working? $ brew doctor # Listen to the doctor
# Run Python 2 $ python # Run Python 3 $ python3 # Install a Python 2 package $ pip install some-package # Install a Python 3 package $ pip3 install some-package
Install the packages.
$ pip install virtualenv $ pip install virtualenvwrapper
Open your shell's profile config (e.g. .bash_profile
, .bashrc
, or .zshrc
). This is usually located in your home directory.
Then add the following:
# ~/.bash_profile # Enable virtualenvwrapper VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python export WORKON_HOME=~/Envs source /usr/local/bin/virtualenvwrapper.sh
On Window, you can use the virtualenvwrapper-powershell.
# Virtualenvwrapper-powershell in Windows PS> pip install virtualenvwrapper-powershell PS> $env:WORKON_HOME="~/Envs" PS> mkdir $env:WORKON_HOME PS> import-module virtualenvwrapper
Create the folder for your virtual environments.
# Reload your profile $ source ~/.bash_profile # Create your env directory $ mkdir -p $WORKON_HOME
Now, when you log in to a new shell session, you will be able to use virtualenvwrapper.
# Create a new environment $ mkvirtualenv my-fresh-environment # Activate an environment $ workon my-fresh-environment # List environments $ lsvirtualenv # Remove an environment $ rmvirtualenv my-polluted-environment
See also: