1

The other day I was trying to delve deeper into this question and provide some insights. Maybe with the additional insights it can finally be solved.

Things to note:

  1. Installing a different Python version is not an option for me (I'd do it in a heartbeat) because I need to use the Gurobi linear programming solver.
  2. matplotlib is compiled with libpng 1.5.14 and linked at runtime just fine. In the IPython console I can use it to plot png figures perfectly.
  3. Because of the previous point I believe the error must occur with the backend used in the IPython Notebook which is also compiled with matplotlib.
  4. I'm trying the whole thing with the source for matplotlib 1.3, if someone can make it work with a previous, not too old version I'd be happy, too.

So, when I try to plot something in the Notebook I get the normal text output from matplotlib put no figure. In the terminal where I started the notebook, I can see the following error:

libpng warning: Application built with libpng-1.2.41 but running with 1.5.14

Since I concluded earlier that the problem must lie in the backend, I checked what libraries are linked there:

otool -L /Library/Python/2.6/site-packages/matplotlib-1.3.0-py2.6-macosx-10.6-universal.egg/matplotlib/backends/_tkagg.so

The output on my system was:

/Library/Python/2.6/site-packages/matplotlib-1.3.0-py2.6-macosx-10.6-universal.egg/matplotlib/backends/_tkagg.so:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
/System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility version 8.5.0, current version 8.5.7)
/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility version 8.5.0, current version 8.5.7)

So the likely offending candidates are Tcl and Tk. Then I ran:

find /System -name libpng\*

and indeed I find:

/System/Library/Tcl/8.4/Img1.4/libpngtcl1.2.24.dylib
/System/Library/Tcl/8.5/Img1.4/libpngtcl1.2.24.dylib

as well as Python shipping its own:

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng.3.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng12.0.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng12.dylib

I went ahead and downloaded the source code for Tcl/Tk 8.6 and compiled them myself in the hope of them compiling against libpng but that wasn't the case. I still got the same error:

libpng warning: Application built with libpng-1.2.41 but running with 1.5.14

When I compile matplotlib it says that due to patches it ships its own libagg and I can't find which tkagg it is using, so maybe that's where things go wrong? Or is the Python 2.6 provided by the system compiled with Tk which is linked against that older libpng?

I guess I could try compiling matplotlib against the libpng version of Tcl/Tk 8.5 or against the one available in the Python framework and see if then both run on libpng version 1.2.41.

Does anyone know where in the backend this might occur and how to fix the compilation to use the right libpng version?

Community
  • 1
  • 1
Midnighter
  • 3,771
  • 2
  • 29
  • 43
  • 1
    you _were_ hijacking the thread, as what you posted was not an answer. Posting a new question is to your benefit as not many people you see your 'question-as-an-answer' anyway. – tacaswell Aug 07 '13 at 02:47
  • and can you replace at least one of your tags with an osx tag? This really needs to be seen by the mac specialists. – tacaswell Aug 07 '13 at 03:29
  • OK, added the osx tag, thanks for the hint. I'm just surprised since there were two other non-answers before mine and at least I tried to solve the question further. – Midnighter Aug 07 '13 at 07:12
  • @Midnighter The other two answers are _not_ non-answers! The difference between their answers and yours was that you were _asking for help_. Non of the others were - one of them simply stated that he/she had almost the exact problem earlier, and then provided his/her solution to that problem. – sodd Aug 07 '13 at 07:23
  • SO is not a discussion board, it is a QA site. Answers should be answers, not discussion of the question. That feature is one of the things that makes the site most useful, when you look up a question, the answers _all_ (in principle) solve the problem so you don't have to wade through a long discussion of related issues. – tacaswell Aug 07 '13 at 16:46

1 Answers1

1

Have you solved the problem yet? I have a similar issue, and I solved it by temporarily renaming the folder containing the header files of libpng shipped with Python (in my case, it's X11) when building matplotlib. After installing matplotlib, rename the folder back.

xuhdev
  • 8,018
  • 2
  • 41
  • 69
  • At some point I was able to give up the dependency of using the system Python. So I compiled my own Python version, then installed the libraries via `HomeBrew` and then compiled matplotlib just fine. – Midnighter May 26 '14 at 18:59