Skip to content

Instantly share code, notes, and snippets.

@pithyless
Created September 10, 2011 21:49
Show Gist options
  • Select an option

  • Save pithyless/1208841 to your computer and use it in GitHub Desktop.

Select an option

Save pithyless/1208841 to your computer and use it in GitHub Desktop.
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

$ mkdir ~/Frameworks
$ ln -s "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework" ~/Frameworks
$ /usr/local/share/python/easy_install pip
$ /usr/local/share/python/pip install --upgrade distribute

Add to .bashrc:

# Before other PATHs...
PATH=${PATH}:/usr/local/share/python

# Python
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/share/python/virtualenvwrapper.sh ]]; then
    source /usr/local/share/python/virtualenvwrapper.sh
else
    echo "WARNING: Can't find virtualenvwrapper.sh"
fi

Install virtualenv

$ pip install virtualenv 
$ pip install virtualenvwrapper

Test setup

$ mkvirtualenv test 
$ rmvirtualenv test
@shurane
Copy link
Copy Markdown

shurane commented Feb 13, 2014

A lot has changed in homebrew and these instructions are out of date. brew install --universal should take care of most of your problems. Also take a look at brew info python for installation instructions.

@bdejong
Copy link
Copy Markdown

bdejong commented Sep 3, 2014

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
    source /usr/local/bin/virtualenvwrapper.sh
else
    echo "WARNING: Can't find virtualenvwrapper.sh"
fi

Also seems to be more recent...

@huanghaihui
Copy link
Copy Markdown

After install python, I find easy_install, virtualenvwrapper.sh and so on in /usr/local/bin not in /usr/local/share/python. just like bdejong shows above.

@yodaqua
Copy link
Copy Markdown

yodaqua commented Apr 15, 2017

still useful, thanks

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