/ mozey.co / blog

python dev on osx yosemite

July 1, 2015

Python Development Environment on Mac OS X Yosemite 10.10

The bundled python on OSX has been modified by Apple. Installed packages might also be removed then the OS is upgraded.

🔗 Install python 2

brew install python

pip install <package>

🔗 Install python 3

brew install python3

pip3 install <package>

🔗 Virtualenv

pip install virtualenv

mkdir ~/.venvs

🔗 Create a virtualenv

cd ~/.venvs

virtualenv -p python3 NAME

source ~/.venvs/NAME/bin/activate

🔗 virtualenv wrapper

pip install virtualenvwrapper

Update profile

vi ~/.profile

export WORKON_HOME=~/.venvs
source /usr/local/bin/virtualenvwrapper.sh

source ~/.profile

How to use virtualenv wrapper

mkvirtualenv -p python3 NAME

workon NAME

deactivate

rmvirtualenv NAME

lsvirtualenv

🔗 Rename virtualenv

Run this after you’ve installed any packages into the environment. If you make an environment relocatable, then install a new package, you must run virtualenv –relocatable again.

The –relocatable option currently has a number of issues, and is not guaranteed to work in all circumstances.

virtualenv --relocatable ENV