9

I have a problem getting matplotlib 1.0.0 to work in Python 2.5.2 (Ubuntu 10.04) See attached console output. Any ideas appreciated. Thanks

Python 2.5.2 (r252:60911, Jul 23 2010, 23:04:44) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import scipy
>>> import matplotlib
>>> print matplotlib.__version__
1.0.0
>>> print numpy.__version__     
1.4.1
>>> print scipy.__version__
0.8.0rc3

>>> from pylab import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.5/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/local/lib/python2.5/site-packages/matplotlib/pylab.py", line 216, in <module>
    from matplotlib import mpl  # pulls in most modules
  File "/usr/local/lib/python2.5/site-packages/matplotlib/mpl.py", line 2, in <module>
    from matplotlib import axis
  File "/usr/local/lib/python2.5/site-packages/matplotlib/axis.py", line 14, in <module>
    import matplotlib.text as mtext
  File "/usr/local/lib/python2.5/site-packages/matplotlib/text.py", line 31, in <module>
    from matplotlib.backend_bases import RendererBase
  File "/usr/local/lib/python2.5/site-packages/matplotlib/backend_bases.py", line 41, in <module>
    import matplotlib.textpath as textpath
  File "/usr/local/lib/python2.5/site-packages/matplotlib/textpath.py", line 9, in <module>
    from matplotlib.mathtext import MathTextParser
  File "/usr/local/lib/python2.5/site-packages/matplotlib/mathtext.py", line 52, in <module>
    import matplotlib._png as _png
ImportError: libpng14.so.14: cannot open shared object file: No such file or directory
>>> 

July 27,01:05 A rebuild of matlibplot gives:

sudo python setup.py build

basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.0.0
                python: 2.5.2 (r252:60911, Jul 23 2010, 23:04:44)  [GCC
                        4.4.3]
              platform: linux2

REQUIRED DEPENDENCIES
                 numpy: 1.4.1
             freetype2: 11.1.5

OPTIONAL BACKEND DEPENDENCIES
                libpng: 1.4.3
               Tkinter: no
                        * TKAgg requires Tkinter
              wxPython: no
                        * wxPython not found
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: no
                    Qt: no
                   Qt4: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: 1.5
                  pytz: 2010h

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: 8.71
                 latex: no
               pdftops: 0.12.4

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab', 'matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra', 'matplotlib.numerix.random_array', 'matplotlib.numerix.fft', 'matplotlib.tri', 'matplotlib.delaunay']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.5/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.linux-i686-2.5/matplotlib/mpl-data
running build_ext



sudo python setup.py install
basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.0.0
                python: 2.5.2 (r252:60911, Jul 23 2010, 23:04:44)  [GCC
                        4.4.3]
              platform: linux2

REQUIRED DEPENDENCIES
                 numpy: 1.4.1
             freetype2: 11.1.5

OPTIONAL BACKEND DEPENDENCIES
                libpng: 1.4.3
               Tkinter: no
                        * TKAgg requires Tkinter
              wxPython: no
                        * wxPython not found
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: no
                    Qt: no
                   Qt4: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: 1.5
                  pytz: 2010h

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: 8.71
                 latex: no
               pdftops: 0.12.4

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab', 'matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra', 'matplotlib.numerix.random_array', 'matplotlib.numerix.fft', 'matplotlib.tri', 'matplotlib.delaunay']
running install
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.5/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.linux-i686-2.5/matplotlib/mpl-data
running build_ext
running install_lib
copying build/lib.linux-i686-2.5/matplotlib/mpl-data/matplotlibrc -> /usr/local/lib/python2.5/site-packages/matplotlib/mpl-data
copying build/lib.linux-i686-2.5/matplotlib/mpl-data/matplotlib.conf -> /usr/local/lib/python2.5/site-packages/matplotlib/mpl-data
running install_egg_info
Removing /usr/local/lib/python2.5/site-packages/matplotlib-1.0.0-py2.5.egg-info
Writing /usr/local/lib/python2.5/site-packages/matplotlib-1.0.0-py2.5.egg-info
askewchan
  • 45,161
  • 17
  • 118
  • 134
Bjorkman
  • 93
  • 1
  • 1
  • 4

3 Answers3

7

You should check your LD_LIBRARY_PATH environnment variable and check that your libpng is in it.

The problem reported by python is a problem of dynamic loading : Nothing to see with the recompilation of matplotlib.

So :

  1. Find the location of libpng.14.so with :

    $> locate libpng.14.so

    Note that the file must have the exact name so you may have to create a symbolic link if for example you have libpng.14.so.0 or something like that (Usually the symbolic links are automatically created when you install your lib

    If you don't have any libpng.14.so.something or libpng.14.so, you may need to reinstall libpng 1.4 (with your package manager or directly from the sources)

  2. Check $LD_LIBRARY_PATH. Change it if you need with :

    $> export LD_LIBRARY_PATH=anewDir:$LD_LIBRARY_PATH

ThR37
  • 3,965
  • 6
  • 35
  • 42
  • 1
    Thanks ELenaher! This tip finally made me able to perform the import of pyplot. The LD_LIBRARY_PATH was empty but now contains the path to usr/local/lib. I read somewhere that it was not recommended to modify this variable? There are however still some issues: Running the plot command now renders a plot on the screen, but it is not possible to fill it with something meaningful. I guess this could be related to installing of Tkinter? I think I'll stick to my working Ipython version for now, and continue my experimenting with OMPC when it supports python 2.6. – Bjorkman Jul 29 '10 at 19:45
  • I'm having exactly the same problem, tried using python2.5 and python2.7. –  Feb 18 '11 at 18:39
0

I had a similar problem with py27-matplotlib from macports. After trying a bunch of things, I noticed that I had an old version of _png.so from matplotlib 1.10 in my site packages. The so linked against libpng14 rather than the newer version I have installed.

After removing the old (unused!) _png.so, running port uninstall/clean py27-matplotlib and a fresh build, the correct libpng was linked and ipython/pylab worked again.

Dana the Sane
  • 14,762
  • 8
  • 58
  • 80
  • I had this problem too, although I'm using the native OSX version of Python 2.7 rather than the Macports version. In my case, simply removing matplotlib and then re-installing it with `easy_install` solved the problem. – Westcroft_to_Apse Dec 03 '12 at 13:01
0

Install libpng. The 14 I believe refers to the current version 1.4.

EDITS

I would rebuild matplotlib from source again. When you run:

python setup.py build

pay close attention to the start of the output and make sure it finds the libraries it needs. For instance on my box:

basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.0.0
                python: 2.5.4 (r254:67916, Oct 21 2009, 11:00:55)  [GCC
                        4.3.2]
              platform: linux2

REQUIRED DEPENDENCIES
                 numpy: 1.3.0
             freetype2: 9.20.3

OPTIONAL BACKEND DEPENDENCIES
                libpng: 1.2.36  ## what does yours say?
               Tkinter: Tkinter: 67737, Tk: 8.4, Tcl: 8.4
              wxPython: 2.8.10.1
                        * WxAgg extension not required for wxPython >= 2.8
                  Gtk+: gtk+: 2.16.1, glib: 2.22.4, pygtk: 2.14.1,
                        pygobject: 2.20.0
       Mac OS X native: no
                    Qt: no
                   Qt4: Qt: 4.5.1, PyQt4: 4.5.4
                 Cairo: 1.8.2

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: matplotlib will provide
                  pytz: 2009r

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: 8.64
                 latex: no
               pdftops: 0.10.7
Mark
  • 106,305
  • 20
  • 172
  • 230
  • Thanks for replies! I believe I've already install libpng.The following was done: Downloaded version 1.4.3 => tar -xvzf libpng-1.4.3.tar.gz => cd libpng-1.4.3 => ./configure => make => make install Shouldn't this be sufficient or are there some additional steps required? – Bjorkman Jul 26 '10 at 13:44
  • @Bjorkman, you should really try and install through your system's package manager. That said, did your compile produce the libpng14.so? If it did, did the make install put in on path (probably /usr/local/lib)? What is the output of "find /usr/lib/ -name libpng*" and "find /usr/local/lib/ -name libpng*"? – Mark Jul 26 '10 at 13:52
  • Looks like the libpng14.so is located in /usr/local/lib/ lu@SilverBeauty:~$ find /usr/lib/ -name libpng* /usr/lib/vmware/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0/libpng12.so.0 ..truncated lu@SilverBeauty:~$ find /usr/local/lib/ -name libpng* /usr/local/lib/libpng14.la /usr/local/lib/libpng14.so.14 /usr/local/lib/libpng14.so /usr/local/lib/libpng.so /usr/local/lib/libpng14.a /usr/local/lib/libpng.a /usr/local/lib/pkgconfig/libpng.pc /usr/local/lib/pkgconfig/libpng14.pc /usr/local/lib/libpng14.so.14.3.0 /usr/local/lib/libpng.la – Bjorkman Jul 26 '10 at 14:30
  • I may mention that I have one version of python 2.6 installed by means of the package manager. By running Ipython on this I can get the matplotlib work correctly. The reason why I'm interested to get it work under Python 2.5 is that I'm testing out ompc (a matlab to python compiler) and this only supports 2.5 – Bjorkman Jul 26 '10 at 14:31
  • @Bjorkeman, very confusing, did you build matplotlib from source as well? If you did, it should have picked up the libpng version 1.2 you have installed in /usr/lib. – Mark Jul 26 '10 at 16:21
  • Yes, the failing matplotlib was built from source. Here are the detailed steps: matplotlib: sudo apt-get install python-matplotlib This unfortunately installed into Python 2.6, which isn't compatible with the ompc. Works great when using: ipython -pylab (from console) In order to get it recognised by the Python 2.5 version: A manual download from sourceforge to ompc/matplotlib and -gunzip matplotlib-1.0.0.tar.gz -tar xvf matplotlib-1.0.0.tar -cd matplotlib-1.0.0/ -sudo python setup.py install Then got following error message: ft2build.h: No such file or directory – Bjorkman Jul 26 '10 at 20:41
  • [cont] This is due to missing freetype: downloaded ~/ompc/freetype-2.4.1 and installed with ./configure [options] make make install (as root) Also need libpng-1.4.3: tar -xvzf libpng-1.4.3.tar.gz (which in turn needs zlib: sudo apt-get install zlib1g-dev) cd libpng-1.4.3 ./configure make make install – Bjorkman Jul 26 '10 at 20:42
  • Hmm, I'm running out of idea, see edits to my answer above, too many comments. – Mark Jul 26 '10 at 22:36
  • Thanks Mark, I really appreciated your effort. I rebuilt the matplotlib as you suggested and the result is added to edits above. After a new install the initial error message still retains. – Bjorkman Jul 26 '10 at 23:02