Last active

PythonMagick on OS X

  • Download Gist

Installing PythonMagick on OS X

  1. brew install boost - will take a lot of time and make your Mac hot
  2. brew install --with-magick-plus-plus imagemagick
  3. cd <path_to_PythonMagick_source>
  4. ./configure --with-boost=<path_to_boost_root>
  5. make
  6. make install
  7. python -c "import PythonMagick"

If PythonMagick build fails saying that it couldn't find -lboost_python navigate to <path_to_boost_root>/lib/, ln -s libboost_python-mt.dylib libboost_python.dylib and run make again.

Tested on 10.6.8 with Python 2.6.7 (custom build). Should work with Lion running stock 2.7.

NOTE: Looks like I was too quick to call it done. The module imports but raises exceptions when used. Bummer.

Did you ever figure out how to solve the import problem?

Unfortunately, I haven't.

I solved this problem by copying from where make install installed PythonMagick /usr/local/lib/python2.7/site-packages/PythonMagick to where Python actually looks on a OS X Lion, /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

Just a quick note for anyone checking this in future, after successfully building PythonMagick on Mac OS X Lion I was getting:

>>> import PythonMagick
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "PythonMagick/", line 1, in <module>
from . import _PythonMagick
ImportError: cannot import name _PythonMagick

This can be fixed by changing the first line of in PythonMagick (Usually to be found in site-packages, in my case /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PythonMagick) from:

from . import _PythonMagick


import _PythonMagick

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.