I am unable to import matplotlib._png
:
import matplotlib._png as _png ImportError:
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/_png.so: undefined symbol: png_set_longjmp_fn
This error prevents me from running import pylab
(sincce this ultimately imports matplotlib._png
).
I installed matplotlib
from source, and made sure to add the path with local installations (/home/james/local
) to basedir
in setupext.py
before running python setup.py install
.
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.7.1]
dateutil: yes [using dateutil version 2.1]
tornado: yes [using tornado version 3.0.1]
pyparsing: yes [using pyparsing version 1.5.7]
pycxx: yes [Couldn't import. Using local copy.]
libagg: yes [pkg-config information for 'libagg' could not
be found Using local copy.]
freetype: yes [version 16.0.10]
png: yes [version 1.2.10]
My research so far:
As can be seen above, matplotlib seems to find version 1.2.10
even though the version that I have under /home/james/local
is 1.6.2
:
$ find . -iname '*libpng*'
./libpng16.so.16.1.0
./libpng16.so
./libpng16.so.16
./libpng16.a
./libpng.a
./libpng.so
./libpng16.la
./pkgconfig/libpng.pc
./pkgconfig/libpng16.pc
./libpng.la
More specifically, I modified the following line in setupext.py
with:
return basedir_map.get(sys.platform, ['/home/james/local', '/usr/local', '/usr'])
but matplotlib seems to have found the system version:
$ locate libpng
/usr/lib/libpng.so
/usr/lib/libpng.so.3
/usr/lib/libpng.so.3.10.0
/usr/lib/libpng12.a
/usr/lib/libpng12.so
/usr/lib/libpng12.so.0
/usr/lib/libpng12.so.0.10.0
Could this be the problem? Why am I unable to import matplotlib._png
?
Update:
Looking at setupext.py
, it looks like python setup install
queries pkg-config
through the SetupPackage
method _check_for_pkg_config
to determine the version of libpng I have installed. It turns out that pkg-config
is returning the system installation:
$ pkg-config --libs libpng
-lpng12
even though I have updated basedir
in matplotlib's setupext.py
, and LD_LIBRARY_PATH
to make them point to the the more recent version of libpng
that I have locally installed.
Any ideas on how to have pkg-config
return the right version?