Installing PythonMagick on OS X
brew install boost
- will take a lot of time and make your Mac hotbrew install --with-magick-plus-plus imagemagick
cd <path_to_PythonMagick_source>
./configure --with-boost=<path_to_boost_root>
make
make install
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.
PythonMagick is working on MacOS Big Sur 11.2.3 with Homebrew and python 3.9
here are my installation steps. After having already installed homebrew;
Install dependencies, including the llvm clang compiler which is required to use OpenMP, since XCode's clang doesn't support it.
brew install python3 boost boost-python3 imagemagick llvm
This will take a while.
Get source
git clone https://github.com/ImageMagick/PythonMagick
cd PythonMagick
Edit
configure
to correctly locate boost-python by replacing two instances ofax_python_lib=boost_python
withax_python_lib=boost_python39
. My entries appear on lines 17992 and 18414. Your exact version of boost_python may vary in future, so checkls -l /usr/local/lib/libboost_python*
first to see).Set BOOST_ROOT (your version may vary)
export BOOST_ROOT=/usr/local/Cellar/boost/1.75.0_2
Run the configure script, telling it explicitly where to find the correct compilers (llvm clang) and which python version and boost libraries to use. Your versions for boost and python may vary.
./configure CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ PYTHON=python3.9 CPPFLAGS="-I/usr/local/Cellar/boost/1.75.0_2/include" LDFLAGS="-L/usr/local/lib"
If the above works, then all that is required now is
make; make install
If the linking step fails during make with an error such as
ld: library not found for -l-L/usr/local/Cellar/imagemagick...
then this indicates that libboost_python wasn't found by the configure script; the hanging-l
is meant to point to-lboost-python39
or similar.Similarly, if you get 'symbol not found' errors at runtime in python, this also indicates a failure to link to libboost-python. Make sure you've run
brew install boost-python3
and usebrew doctor
to check for any broken links. Also make sure you're not linking against any "legacy" libraries, especially if like me you upgraded to Big Sur over the top of Mojave or Catalina. You might want to wipe away libboost_python and completely reinstall it if this happens.python3 -c 'import PythonMagick'
. If successful, there should be no output / errors.