Use virtualenv to switch between multiple environments.
The procedure is on the Official Site,
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
You can install it with. Also, if xcode is not included, enter Command Line Tools.
$ brew doctor
If you get a warning, respond Your system is ready to brew. I will try to come out.
$ brew install python
Will install python2.7. easy_install and pip are also installed at the same time.
Setuptools and Pip have been installed. To update them
pip install --upgrade setuptools
pip install --upgrade pip
To symlink "Idle" and the "Python Launcher" to ~/Applications
`brew linkapps`
Is displayed, follow the instructions to execute the command.
Install virtualenv and virtualenvwrapper with pip.
$ pip install virtualenv virtualenvwrapper
Since we need to load virtualenvwrapper.sh Set it to .bashrc etc.
export VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python/2.7.5/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENV_USE_DISTRIBUTE=true
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
fi
Normally, you can only install the latest version of python2 series and the latest version of python3 series. Make it possible to install other versions with the following command.
$ brew tap homebrew/versions
When you can, install the version you want to use.
$ brew install python25 python26 python3
This will install python 2.5, 2,6, 3.3.
$ mkvirtualenv --python='/usr/local/Cellar/python26/2.6.8/bin/python' py26
Then you will have a Python 2.6 virtual environment named py26.
To use this environment
$ workon py26
will do.
To return to the normal environment
$ deactivate
is.
Recommended Posts