2

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!!!

4
  • 2
    Not a solution to your problem, but you might want to check out the Enthought Python distribution. It contains matplotlib ready to go, plus other tools that are often tricky to install on OS X. Commented Jul 12, 2012 at 13:41
  • What did you do to install matplotlib? Did you compile from source? I suggest you install Enthought's python distribution like what @ChrisP says. Commented Jul 12, 2012 at 18:10
  • The enthought package fixed the problem. Thank you, Chris! I got the matlablib from Github and compiled from the source code. Anyway, thank you, too, Jason! Commented Jul 12, 2012 at 19:16
  • Did you try the setup.py file instead of the make.osx? I have no problems with the former when using homebrew, and I was under the impression that it just works without homebrew too. In this case, it sounds like using enthought was the best answer. Commented Jul 13, 2012 at 13:01

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.