I have 2 pythons on my mac (10.8.3): The default, and 2.7 version from homebrew.

So far, I could install modules and use them with my brew python. I installed mapnik with brew install mapnik (mapnik-2.1.0) and it compiled correctly. But, if I open python and enter import mapnik, the following error comes and python exits:

Indeed, this error shows up when a module tries to use a python library that is different than the one the interpreter uses, that is, when you mix two different pythons. The list of Binary Images does show two occurrences of org.python.python: one by homebrew, and one in /System/Library/... To find out which library uses the latter, I would run otool -L <dyld> on each of the dynamic libraries in the list of Binary Images, and see which ones is linked to the system Python.
– user707650Mar 28 '13 at 13:22

1

@Evert I'm having (basically) the same problem, except between my system python and MacPorts python. The list of dynamic libraries in these error messages are pretty extensive... is there any easier way than using otool on each one? Thanks
– DilithiumMatrixJun 29 '13 at 1:15

@Evert I'm having the same issue, can you please tell me what does <dyld> mean?
– Jack TwainMar 6 '14 at 23:47

1

@zhermes I'm having the exact same problem as yours "system python and MacPorts python". How did you solve it please?
– Jack TwainMar 6 '14 at 23:47

@AlexTwain <dyld> is just a placeholder name. Replace it by the full path name of each dynamic library in the list (i.e., the names ending in .dylib. The full path isn't given unfortunately, but finding that may quickly point you to the actual problem, as you'll notice the path is totally different than the Python you're using (for example, the libboost_python-mt.dylib listed above could be a system one, while the given Python is a homebrew one.)
– user707650Mar 7 '14 at 7:33

4 Answers
4

It looks like you are running the homebrew python but either boost python or mapnik's python bindings ended up linking against the system python provided by apple. If a full clean and reinstall of boost and Mapnik does not fix this then I recommend stopping by #mapnik irc on freenode for help debugging. Generally to fix you need to call otool -L on boost_python.dylib and or on 'site_packages/mapnik/_mapnik.so' to see which ended up with a linkage to the system python. Then you can fix by using install_name_tool.

There are a lot of situations where changing the active python cannot be done, for example, when you have installed a bunch of modules, or libraries in the macports python. The solution for otmezger problem can only be resolved by using "install_name_tool" command line tool. This thread gives information about using this tool developer.leapmotion.com/documentation/python/devguide/…
– LM.CroisezMay 13 '15 at 21:31

I face the similar problem in using androguard. Though it's not quite the same, it can be a reference. My crash also is "Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6". Run "otool -L ", suggest the dylib link to the system python.
Try solution: