user1520172
user1520172

Reputation: 21

Python matplotlib library install in max os x

I am trying to install matplotlib library for Python. The installation was OK but I got the following error when I imported pylab (e.g. import pylab as p) in Python.


File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mathtext.py", line 61, in <module>
    import matplotlib._png as _png

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so, 2): Symbol not found: _png_set_longjmp_fn

  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so

  Expected in: flat namespace  in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so

Google searches indicate that the link error (which does not look for "_png_set_longjmp_fn" ) is related to a 32/64 bit compiling issue for the png library.

I tried to re-install matplotlib based on README.osx file in the library but it was not fixed. Other methods that I found did not resolve it. Also, I checked out if the libraries are compiled at 32 or 64 bit. The relevant binaries support both ( universal binaries) as follows.


>file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so 

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so: Mach-O universal binary with 2 architectures

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so (for architecture i386):   Mach-O bundle i386

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so (for architecture x86_64): Mach-O 64-bit bundle x86_64


>file /Library/Frameworks/libpng.framework/Versions/Current/libpng 

/Library/Frameworks/libpng.framework/Versions/Current/libpng: Mach-O universal binary with 2 architectures

/Library/Frameworks/libpng.framework/Versions/Current/libpng (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

/Library/Frameworks/libpng.framework/Versions/Current/libpng (for architecture i386):   Mach-O dynamically linked shared library i386

My OS X version is Lion 10.7.4. Do you have any idea on this problem? Thanks!!!

Upvotes: 2

Views: 1400

Answers (1)

Leo Mizuhara
Leo Mizuhara

Reputation: 375

I got the same issue as yours the other day when I did from matplotlib import pyplot the other day. After five hours of slamming my head against the wall, this solution worked for me (from practicalcomputing.org

I got this set of commands to set up simlinks:

sudo mkdir -p /usr/local/include
sudo ln -s /usr/X11/include/freetype2/freetype /usr/local/include/freetype
sudo ln -s /usr/X11/include/ft2build.h /usr/local/include/ft2build.h
sudo ln -s /usr/X11/include/png.h /usr/local/include/png.h
sudo ln -s /usr/X11/include/pngconf.h /usr/local/include/pngconf.h
sudo ln -s /usr/X11/include/pnglibconf.h /usr/local/include/pnglibconf.h
sudo mkdir -p /usr/local/lib
sudo ln -s /usr/X11/lib/libfreetype.dylib /usr/local/lib/libfreetype.dylib
sudo ln -s /usr/X11/lib/libpng.dylib /usr/local/lib/libpng.dylib

It doesn't quite solve all your issues, but it solved my pkg-config issue (among others). Perhaps a similar link would help with QT.

Upvotes: 2

Related Questions