Skip to content

Instantly share code, notes, and snippets.

@maxxst
Last active January 7, 2018 13:01
Show Gist options
  • Save maxxst/a76b3b8888b4245c3b91 to your computer and use it in GitHub Desktop.
Save maxxst/a76b3b8888b4245c3b91 to your computer and use it in GitHub Desktop.
Cheat Sheet for virtualenvwrapper

Cheat Sheet for virtualenvwrapper

This is what I did to set up my python development system on my mac

First Steps:

  1. brew install python, python3
  2. pip --user install virtualenvwrapper

Add this to .zshrc

# everything for virtualenvwrapper
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2
export WORKON_HOME=~/Envs
export PROJECT_HOME=~/Projekte/Python
source /usr/local/bin/virtualenvwrapper.sh

## Helper Commands
mkvenv2() {mkvirtualenv -p $which=python2 "$*";}
mkvenv3() {mkvirtualenv -p $which=python3 "$*";}

## better exit:
alias workoff="deactivate"

Commands

Create a new python2 env (the easy way)

mkvenv2 test_python_2

in that env python --version will return 2.x

Create a new python3 env (the easy way)

mkvenv3 test_python_3

in that env python --version will return 3.x

Join an environment

workon test_python_x

The Hard Way

Create a new python2 env (the hard way)

mkvirtualenv -p /usr/local/bin/python test

in that env python --version will return 2.x

Create a new python3 env (the hard way)

mkvirtualenv -p /usr/local/bin/python3 test3

in that env python --version will return 3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment