Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
    
Have you tried running brew link python and then python --version on a fresh terminal? –  Rash Aug 15 '12 at 15:55
    
@user1099816 Python is already linked in /usr/local/bin, and the Python version in my path is 2.7.3. –  Stephen Jennings Aug 16 '12 at 5:06
    
I can't reproduce this... I think we're missing something about you're environment. The symlink to: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current/lib/‌​python2.7/config -- mentioned in the previous question... is that backwards? –  ranman Aug 16 '12 at 6:35
    
@ranman /usr/local/lib/python2.7/config is symlinked to /usr/local/Cellar/.../lib/python2.7/config, which contains config.c, among other files. –  Stephen Jennings Aug 17 '12 at 3:49
    
Are you installing the same formula version and the exact same MacVim version on both systems? Maybe something broke between releases and your upgrades are unrelated? –  Daniel Beck Aug 18 '12 at 16:19
show 1 more comment

2 Answers

up vote 20 down vote accepted
+200

Not a good answer here, but I wanted to leave a note confirming that I encountered this exact same issue on a ~fresh Mountain Lion install.

There is some interesting discussion at the link below which suggests a controversial bug between the MacVim and Python configure files ... but making the suggested change in the config file did not work for me (assuming I did it right).

http://stackoverflow.com/questions/6490513/vim-failing-to-compile-with-python-on-os-x/8276426#8276426

What did work for me is, ahem, biting the bullet and just symlinking the system python install over to the homebrew. Feels dirty, but at least I get full omnicomplete working on third party modules now...

cd /System/Library/Frameworks/Python.framework/Versions
sudo mv Current Current-sys
sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7 Current

brew install macvim

sudo mv Current Current-brew
sudo mv Current-sys Current
share|improve this answer
    
A-ha! So I tried first modifying the Makefile, then also symlinking the framework in /System/Library/Frameworks, and now it works even after restoring the symlink. I'll go back and figure out if both were necessary, and maybe try to dig into what the heck is happening, but you definitely get my thanks (and bounty; not bad getting 200 rep for your first answer)! –  Stephen Jennings Aug 24 '12 at 4:08
1  
Yes, even if I put the Makefile back, as long as I have /System/Library/.../Current symlinked to Homebrew's version, MacVim compiles with 2.7.3. –  Stephen Jennings Aug 24 '12 at 4:23
    
Awesome! So glad it worked out. Happy Vimming. –  Mike Repass Aug 24 '12 at 19:17
    
Just wanted to say that this fixed my problem as well. –  Jeremy Cantrell Sep 21 '12 at 2:53
add comment

I just pushed a fix1 so that MacVim builds with a brewed Python (if you have one) and successfully load the powerline (I installed it after my brewed python via pip install pip install git+git://github.com/Lokaltog/powerline). Don't forget to set your ~/.vimrc.

Don't ever rename things inside of /System.

Please, revert local changes, restore your /System, brew update and brew rm macvim and finally brew install macvim.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.