Based on http://ymotongpoo.hatenablog.com/entry/20120516/1337123564 Unfortunately, pythonbrew is owkn... Let's use virtualenv for switching multiple Python versions!
Install Python and related tools
I mainly use Python3 :) Latest Python3 version in Homebrew is Python 3.2.3.
% brew install python3
% /usr/local/share/python3/easy_install3 pip
% /usr/local/share/python3/easy_install3 virtualenv
% /usr/local/share/python3/easy_install3 virtualenvwrapper
Configuration in .zshrc
PYTHON_VER=3.2
export HOMEBREW_PREFIX=/usr/local
export VIRTUALENVWRAPPER_PYTHON=$HOMEBREW_PREFIX/bin/python$PYTHON_VER
export VIRTUALENV_BIN=$HOMEBREW_PREFIX/share/python3
export WORKON_HOME=$HOME/.virtualenvs
. $VIRTUALENV_BIN/virtualenvwrapper.sh
export PATH=$VIRTUALENV_BIN:$PATH
mkvenv ()
{
base_python=`which python$1`
mkvirtualenv --distribute --python=$base_python $2
}
Try!
% source .zshrc
% mkvenv 3.2 dev
(dev)% which python
$WORKON_HOME/dev/bin/python
(dev)% python -V
Python 3.2.3
(dev)% pip install tornado
(dev)% deactivate
% source $WORKON_HOME/dev/bin/activate
(dev)%
Recommended Posts