Modified to make it work with my current OSX homebrew python installation. This won't work with linux or other OSX python installations. Need to fix that later.