OS X, Hombrew, MacVim and Python 2.7.1 troubles

by sethtrain

Recently I decided to switch over to Vim from Emacs. It was just a test to see what a Python development environment would be like and I must say I am quite pleased. I ran into a couple of problems along the way. This article got me started. The process I am about to detail wasn’t what I really wanted but it accomplishes my end goal which was to have MacVim set up to use my “homebrewed” Python install and work well with the virtualenv settings discussed in the article.

Python needs to be installed with the “framework” option:

$ brew install python --framework

Next you need to update the “Current” OS X symbolic link:

$ cd /System/Library/Frameworks/Python.framework/Versions/
$ sudo rm Current
$ sudo ln -s /usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/Current

If you have to remove your current python installation (installed with homebrew) you may need to reinstall setuptools, pip, virtualenv, virtuelenvwrapper, etc.

For my virtualenvwrapper to work correctly I needed to take these steps and set up my .bashrc file accordingly:

$ cd /usr/local/share
$ ln -s ../Cellar/python/2.7.1/bin python

Update .bashrc:

$ export PATH=/usr/local/share/python:$PATH

Next you must install MacVim from source. Download the latest package, untar and configure:

$ cd b4winckler-macvim-6e6fac5
$ ./configure --enable-gui=macvim --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --with-python-config-dir=/usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
$ make
$ cp -R src/MacVim/build/Release/MacVim.app /Application

Once this is done everything seemed to work perfect! On my Ubuntu VM I didn’t have to do anything special like this so I mark it up with how Mac OS X handles Frameworks differently from other Unix/Linux systems.

Hope this helps!

Update:

To use this compiled version in your terminal I found this alias helpful:

alias vim='/Applications/MacVim.app/Contents/MacOS/Vim'