How can I use the Homebrew Python with Homebrew MacVim on Mountain Lion?

Posted by Stephen Jennings on Super User See other posts from Super User or by Stephen Jennings
Published on 2012-08-15T05:29:49Z Indexed on 2012/09/01 15:40 UTC
Read the original article Hit count: 508

Filed under:
|
|
|
|

I originally asked and answered this question: How can I use the Homebrew Python version with Homebrew MacVim?

These instructions worked on Snow Leopard using Xcode 4.0.1 and associated developer tools. However, they no longer seem to work on Mountain Lion with Xcode 4.4.1.

My goal is to leave the system's version of Python completely untouched, and to only install PyPI packages into Homebrew's site-packages directory. I want to use the vim_bridge package in MacVim, so I need to compile MacVim against the Homebrew version of Python.

I've edited the MacVim formula to add these to the arguments:

--enable-pythoninterp=dynamic
--with-python-config-dir=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current/lib/python2.7/config

Then I install with the command:

brew install macvim --override-system-vim --custom-icons --with-cscope --with-lua

However, it still seems to be somehow using Python 2.7.2 from the system. This seems strange to me because it also seems to be using the correct executable.

:python print(sys.version)
2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

:python print(sys.executable)
/usr/local/bin/python

$ /usr/local/bin/python --version
Python 2.7.3

$ /usr/local/bin/python -c "import sys; print(sys.version)"
2.7.3 (default, Aug 12 2012, 21:17:22) 
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))]

$ readlink /usr/local/lib/python2.7/config
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current/lib/python2.7/config

I've removed everything in /usr/local and reinstalled Homebrew by running these commands:

$ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
$ brew install git mercurial python ruby
$ brew install macvim
   (nope, still broken)
$ brew remove macvim
$ ln -s /usr/local/Cellar/python/..../python2.7/config /usr/local/lib/python2.7/config
$ brew install macvim

© Super User or respective owner

Related posts about osx

Related posts about vim