Python Virtual Environment

Step 1 Preparation

# Install virtual environment
pip install virtualenv virtualenvwrapper
echo "# Virtual Environment Wrapper"
echo "VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2" >> ~/.bash_profile
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bash_profile
source ~/.bash_profile

Step 2 Create Virtual Environment

# python2
mkvirtualenv <envname> -p python2

# python3
mkvirtualenv <envname> -p python3

Work on the Virtual Environment

workon <envname>

Quit Virtual Environment

deactivate

Delete Virtual Environment

rmvirtualenv <envname>