2

I am pretty new to Python, having just taken a course and now trying to apply what I learned to convert matlab code to python. I have to plot some things, so I tried to import matplotlib.pyplot but keep getting

Incompatible library version: _png.so requires version 42.0.0 or later, but libpng12.0.dylib provides version 41.0.0

I don't really understand how to either update my libpng12.0.dylib (since I am not really a programmer, just someone who wants to learn python, so please be easy on me if this is a super easy question!), or tell my _png.so to look somewhere else, if that is appropriate. I have done a lot of digging in to this, and I know that there are a number of issues with installing matplotlib on osX, but I haven't seen anything about how to resolve this one.

I am running Enthought Canopy, using python 2.7, and I am running OS X 10.8

I really appreciate any help

user1775563
  • 317
  • 3
  • 8
  • Is this from within the Canopy GUI or when running (i)python in Terminal? If the latter, please try from within the Canopy GUI to see whether the problem is there as well. – Jonathan March Jan 11 '14 at 00:07
  • It was within the Canopy GUI. I was nervous about using the python in terminal - I didn't think the packages would all be there. Thanks – user1775563 Jan 19 '14 at 18:35

1 Answers1

1

Check your DYLD_LIBRARY_PATH and LD_LIBRARY_PATH. Make sure that you have your library paths in the right order. I changed mine recently due to a matlab install and it took ages before I made the connection that it was my LD_LIBRARY_PATH that was stuffed. Programs go searching for the libraries in the order specified by those paths. If you have another libpng (as I did) in a library path before the canopy one, then it will use that. Fine if the version is recent, otherwise you get these errors.

First unset them both and then run python and your plot. Hopefully that works. Then go about fixing your DYLD_LIBRARY_PATH and LD_LIBRARY_PATH.

I put these at the front of both /opt/local/lib:/Users/xxxxx/Library/Enthought/Canopy_64bit/User/lib

My error was ...

/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/_png.so Reason: Incompatible library version: _png.so requires version 41.0.0 or later, but libpng12.dylib provides version 40.0.0

Phil V
  • 11
  • 2
  • Same problem : could you explain how to check the DYLD_LIBRARY_PATH and the LD_LIBRARY_PATH ? – hhh Nov 13 '14 at 23:10
  • It will depend on the shell you use. I'd guess bash since that's the default. In you home folder under /Users there should be a .profile or .bashrc . try open .bashrc In there you will probably have something like export DYLD_LIBRARY_PATH=/Some/paths/separated/by/colons:/another you need to make sure the path to the correct version is first... and even possibly removing the other incorrect one. – Phil V Apr 16 '15 at 01:07