matplotlib installation error

Hi,

I have been having problems trying to install matplotlib properly on our server. Our environment is Debian 4.1.1-21, Python2.4 , and I have installed all the required modules (numpy, Numeric etc). I originally tried installing matplotlib from source, but the build was unsuccessful. I was getting this error when I tried building matplotlib-0.90.1:

python setup.py build

building for GTK requires pygtk; you must be able to "import gtk" in your build/install environment
TKAgg requires TkInter
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc ->
build/lib.linux-x86_64-2.3/matplotlib/mpl-data
running build_ext
building 'matplotlib.backends._na_backend_agg' extension
c++ -pthread -shared
build/temp.linux-x86_64-2.3/agg23/src/agg_trans_affine.o
build/temp.linux-x86_64-2.3/agg23/src/agg_path_storage.o
build/temp.linux-x86_64-2.3/agg23/src/agg_bezier_arc.o
build/temp.linux-x86_64-2.3/agg23/src/agg_curves.o
build/temp.linux-x86_64-2.3/agg23/src/agg_vcgen_dash.o
build/temp.linux-x86_64-2.3/agg23/src/agg_vcgen_stroke.o
build/temp.linux-x86_64-2.3/agg23/src/agg_rasterizer_scanline_aa.o
build/temp.linux-x86_64-2.3/agg23/src/agg_image_filters.o
build/temp.linux-x86_64-2.3/src/_image.o
build/temp.linux-x86_64-2.3/src/ft2font.o
build/temp.linux-x86_64-2.3/src/mplutils.o
build/temp.linux-x86_64-2.3/CXX/IndirectPythonInterface.o
build/temp.linux-x86_64-2.3/CXX/cxx_extensions.o
build/temp.linux-x86_64-2.3/CXX/cxxsupport.o
build/temp.linux-x86_64-2.3/CXX/cxxextensions.o
build/temp.linux-x86_64-2.3/src/_na_backend_agg.o -L/usr/local/lib
-L/usr/lib -L/usr/lib64 -L/usr/local/lib -L/usr/lib -L/usr/lib64 -lpng
-lz -lstdc++ -lm -lfreetype -lz -lstdc++ -lm -o
build/lib.linux-x86_64-2.3/matplotlib/backends/_na_backend_agg.so
/usr/bin/ld: /usr/local/lib/libpng.a(png.o): relocation R_X86_64_32
against `a local symbol' can not be used when making a shared object;
recompile with -fPIC
/usr/local/lib/libpng.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: command 'c++' failed with exit status 1

So I tried installing matplotlib from distribution (ie. using apt-get install python-matplotlib), thinking it may work instead of me trying to manually install it. The distribution installs matplotlib-0.87.7, which is older than the current version available by source. And it seemed to compile fine without any errors. However, when I try to import pylab using python command line, I get this error:

import matplotlib
import pylab

Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "pylab.py", line 1, in ?
     from matplotlib.pylab import *
   File "matplotlib/pylab.py", line 197, in ?
     import cm
   File "matplotlib/cm.py", line 5, in ?
     import colors
   File "matplotlib/colors.py", line 33, in ?
     from numerix import array, arange, take, put, Float, Int, where, \
   File "matplotlib/numerix/__init__.py", line 75, in ?
     from _sp_imports import nx, infinity, rand, randn, isnan, all, any
   File "matplotlib/numerix/_sp_imports.py", line 9, in ?
     from numpy import Int8, UInt8, \
ImportError: cannot import name Int8

I think this Debian distribution of matplotlib (which is older than the current release) is incompatible with the current version of numpy/Numeric that I have installed, but I'm not sure. I would rather have the latest matplotlib vesrion installed (version 0.90.1), but I can't seem to get it to even build properly.

I'm stumped and I'm hoping someone has an idea why I might be getting this error, and how I can get around it. Please let me know if you need more information if it helps understand the problem better. Thanks in advance,

best,
Hardeep

build/temp.linux-x86_64-2.3/src/_na_backend_agg.o -L/usr/local/lib
-L/usr/lib -L/usr/lib64 -L/usr/local/lib -L/usr/lib -L/usr/lib64 -lpng
-lz -lstdc++ -lm -lfreetype -lz -lstdc++ -lm -o
build/lib.linux-x86_64-2.3/matplotlib/backends/_na_backend_agg.so
/usr/bin/ld: /usr/local/lib/libpng.a(png.o): relocation R_X86_64_32
against `a local symbol' can not be used when making a shared object;
recompile with -fPIC
/usr/local/lib/libpng.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: command 'c++' failed with exit status 1

You need to either recompile libpng so it builds a shared library or delete `/usr/local/lib/libpng.a' so gcc picks up the default version provided by Debian.

I think this Debian distribution of matplotlib (which is older than
the current release) is incompatible with the current version of
numpy/Numeric that I have installed, but I'm not sure. I would rather
have the latest matplotlib vesrion installed (version 0.90.1), but I
can't seem to get it to even build properly.

Did you install your own copy of numpy or are you using the one that comes with Debian? If you're using the one that comes with Debian, I'll try to reproduce the problem and file a bug report.

Ken

···

On Aug 29, 2007, at 1:59 PM, Hardeep Nahal wrote:

Yes, I think my libpng library was corrupt, but when I tried reinstalling, it still wouldn't work. So I deleted it, as Ken suggested, and it worked. I think it wasn't finding the default libpng, and was going straight to the corrupted version. I spent the whole day trying to figure this out! :stuck_out_tongue_winking_eye: , so thank you very much Ken and Jouni for your suggestions.

It appears the matplotlib and numpy packages that come with Debian are incompatible. But I installed matplotlib 0.90.1 and numpy 1.0.3-2 on my own, and after fixing that libpng error, they appear to be compatible.

Hardeep

Quoting Ken McIvor <mcivor@...227...>:

···

On Aug 29, 2007, at 1:59 PM, Hardeep Nahal wrote:

build/temp.linux-x86_64-2.3/src/_na_backend_agg.o -L/usr/local/lib
-L/usr/lib -L/usr/lib64 -L/usr/local/lib -L/usr/lib -L/usr/lib64 -lpng
-lz -lstdc++ -lm -lfreetype -lz -lstdc++ -lm -o
build/lib.linux-x86_64-2.3/matplotlib/backends/_na_backend_agg.so
/usr/bin/ld: /usr/local/lib/libpng.a(png.o): relocation R_X86_64_32
against `a local symbol' can not be used when making a shared object;
recompile with -fPIC
/usr/local/lib/libpng.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: command 'c++' failed with exit status 1

You need to either recompile libpng so it builds a shared library or
delete `/usr/local/lib/libpng.a' so gcc picks up the default version
provided by Debian.

I think this Debian distribution of matplotlib (which is older than
the current release) is incompatible with the current version of
numpy/Numeric that I have installed, but I'm not sure. I would rather
have the latest matplotlib vesrion installed (version 0.90.1), but I
can't seem to get it to even build properly.

Did you install your own copy of numpy or are you using the one that
comes with Debian? If you're using the one that comes with Debian,
I'll try to reproduce the problem and file a bug report.

Ken

Yes, I think my libpng library was corrupt, but when I tried
reinstalling, it still wouldn't work.

It's not corrupt, it's just not the correct kind of library. There are two types: static libraries (.a), which get compiled into a program, and shared libraries (.so), which are stored outside of the program. Trying to compile a shared library that uses a static library is always a bit dodgy and sometimes fails completely. If you really need to use your own copy of libpng you should re-run the configure script with the "--enable-shared" option and then recompile. Since you're using Debian I'd advise you to just use the libraries it provides whenever possible. That ought to make your life easier.

It appears the matplotlib and numpy packages that come with Debian are
incompatible.

I have been unable to reproduce the problem you were having with the Debian matplotlib and numpy packages. I'd appreciate more details about the packages you had installed, if you don't mind breaking your system again briefly. Could you please reinstall them, verify that the problem still occurs, and then email me the output of the following four commands? If you don't have time to work on this right now don't worry about it.

Here are the commands which will provide me with the information I require:

   cat /etc/debian\_version &nbsp;&nbsp; dpkg -s python
   dpkg \-s python\-numpy &nbsp;&nbsp; dpkg -s python-numarray

Thanks,
Ken

···

On Aug 29, 2007, at 5:12 PM, Hardeep Nahal wrote: