Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib -- libpng error: Incompatible libpng version in application and library

I installed matplotlib via

pip install matplotlib

When I try to save png with it, I get

Application was compiled with png.h from libpng-1.6.21
libpng warning: Application  is  running with png.c from libpng-1.2.44
libpng error: Incompatible libpng version in application and library

ldconfig -p | grep libpng gives me

libpng12.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libpng12.so.0
libpng12.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpng12.so.0
libpng12.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpng12.so

I then build libpng1.6.21 from source and add its lib/ to my LD_LIBRARY_PATH. But ldconfig -p | grep libpng still gives me the samething as before. I tried rebuilding the ldconfig -- still only libpng12.

How can I let matplotlib pick up the newly installed libpng1.6.21?

Why is the new libpng1.6.21 in my LD_LIBRARY _PATH already, but not indexed by ldconfig?

like image 783
Sibbs Gambling Avatar asked Aug 01 '17 22:08

Sibbs Gambling


2 Answers

I met the same problem before. But if matplotlib was imported first, it worked fine. I have no idea why.

like image 111
Xianzhi Cao Avatar answered Oct 18 '22 11:10

Xianzhi Cao


A quick workaround would be to run your interpreter / script by specifying a custom value for LD_LIBRARY_PATH, e.g.:

LD_LIBRARY_PATH=/your/ld/path python

or:

 export LD_LIBRARY_PATH=/your/ld/path
 python

For more permanent solutions, you may want to update the LD_LIBRARY_PATH in .profile or similar.

like image 41
norok2 Avatar answered Oct 18 '22 09:10

norok2