Mountain Lion and homebrew vim: “ImportError: No module named site”

If you use homebrew’s macvim recipe, Mountain Lion, and any of the vim plugins that use the python support (such as the excellent Gundo, which provides a handy navigable graph of your vim undo history for a buffer), you should remove and reinstall macvim:

brew rm macvim
brew install macvim

The upgrade to Mountain Lion changed the system Python environment sufficiently to cause vim to crash (with an unhelpful “ImportError: No module named site” message to stderr) if you try to execute python, for instance by triggering Gundo.

(This may also affect things that use Ruby bindings, such as the Command-T fuzzy-file-finder plugin. I ran into the Python issue first, and after reinstalling macvim, Command-T works fine.)

Edit: As observed below, if you have a homebrew version of python installed, you may need to unlink it while rebuilding macvim.

5 Responses