homebrew macvim with python2.7.3 support not working

I installed macvim with homebrew, with python support. My incantation was as follow:

brew install macvim --override-system-vim

Now when I open a python file, I get a series of errors if I try to import anything. e.g. if I import re I see ImportError: no module name re.

The first time I open macvim after installing, I get 'import site' failed; use -v for traceback in the terminal where I opened macvim. This is after running my first python command.

What does this mean and and how do I fix it?

Answers


I got this working with a quick hack where you temporarily point the system python to your preferred python:

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

brew rm macvim # optionall, only if you had it installed previously  
brew install macvim --override-system-vim

sudo mv Current-sys Current
sudo mv 2.7-sys 2.7

my wild guess is that you should add the homebrew install folder to your .bash_profile like this:

export PATH=/usr/local/bin:/usr/local/sbin:usr/local/Cellar/python/2.7.3/bin:$PATH

after that write in the shell "source .bash_profile" so it reloads. Also please check the output of

which python 

to make sure you are using homebrew python


I ended up giving up on the homebrew option and using the answer suggested here:

vim compiles with wrong python version (and not working with needed version)

It's a shame it appears this cant be done via brew. Looks like somebody needs to patch the macvim distribution itself.


Need Your Help

How to write code in Visual Studio faster?

c# .net visual-studio-2008 performance

Whenever I start a new software project I spend a good amount of time at the beginning drawing class diagrams and other flow charts to plan out how I see the application working. This part just tak...