Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_backend_agg.so: undefined symbol: MPL_matplotlib__path_ARRAY_API #2577

Closed
gandalf013 opened this issue Nov 4, 2013 · 14 comments
Closed

_backend_agg.so: undefined symbol: MPL_matplotlib__path_ARRAY_API #2577

gandalf013 opened this issue Nov 4, 2013 · 14 comments
Assignees
Labels
Milestone

Comments

@gandalf013
Copy link

I am trying to build and install matplotlib on a RHEL 5.8 system:

$ lsb_release -a
LSB Version:    :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Release:        5.8
Codename:       Tikanga

I have numpy 1.8.0 installed. I have tried building and installing matplotlib 1.3.1 or 1.3.0. The installation succeeds, but then importing matplotlib.pyplot returns:

In [2]: import matplotlib.pyplot as plt
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "/prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 38, in <module>
    from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg
ImportError: /prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/backends/_backend_agg.so: undefined symbol: MPL_matplotlib__path_ARRAY_API

The MPL_matplotlib__path_ARRAY_API symbol is defined in _path.so file, but is undefined in backends/_backend_agg.so:

$ nm backends/_backend_agg.so | grep ARRAY_API
         U MPL_matplotlib__path_ARRAY_API
000776c0 B MPL_matplotlib_backends__backend_agg_ARRAY_API
00014280 t _GLOBAL__I_MPL_matplotlib_backends__backend_agg_ARRAY_API

I am not sure why _backend_agg.so is referring to MPL_matplotlib__path_ARRAY_API. On a more modern system (Linux Mint 13), the output from the above command is:

000000000026b438 B MPL_matplotlib_backends__backend_agg_ARRAY_API

I built matplotlib with the following:

$ python setup.py build
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Extracting in /tmp/tmp6y4XL0
Now working in /tmp/tmp6y4XL0/distribute-0.6.28
Building a Distribute egg in /prod/home/alok/Downloads/matplotlib-1.3.1
/prod/home/alok/Downloads/matplotlib-1.3.1/distribute-0.6.28-py2.6.egg
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [1.3.1]
                python: yes [2.6.4 (r264:75706, Apr 12 2012, 06:55:25)  [GCC
                        4.1.2 20080704 (Red Hat 4.1.2-46)]]
              platform: yes [linux2]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.8.0]
              dateutil: yes [using dateutil version 1.5]
               tornado: yes [tornado was not found. It is required for the
                        WebAgg backend. pip/easy_install may attempt to
                        install it after matplotlib.]
             pyparsing: yes [matplotlib requires pyparsing >= 1.5.6]
                 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 9.10.3]
                   png: yes [version 1.2.10]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [using nose version 0.11.1]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt4agg: no  [PyQt4 not found]
               gtk3agg: no  [Requires pygobject to be installed.]
             gtk3cairo: no  [Requires cairo to be installed.]
                gtkagg: no  [Requires pygtk]
                 tkagg: yes [installing, version 73770]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: no  [cairo not found]
             windowing: no  [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
                dvipng: yes [version 1.5]
           ghostscript: yes [version 8.70]
                 latex: yes [version 3.141592]
               pdftops: no

Other information:

$ gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ python -V
Python 2.6.4
$ python -c 'import numpy; print numpy.__version__'
1.8.0

Am I doing something wrong?

@mdboom
Copy link
Member

mdboom commented Nov 4, 2013

It seems that you have Numpy 1.3.0 installed, at least on the system where
it isn't working. matplotlib doesn't support numpy < 1.5, and that is most
likely the cause of this error.

On Mon, Nov 4, 2013 at 2:13 PM, Alok Singhal notifications@github.comwrote:

I am trying to build and install matplotlib on a RHEL 5.8 system:

$ lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Release: 5.8
Codename: Tikanga

I have numpy 1.8.0 installed. I have tried building and installing
matplotlib 1.3.1 or 1.3.0. The installation succeeds, but then importing
matplotlib.pyplot returns:

In [2]: import matplotlib.pyplot as plt

Traceback (most recent call last):
File "", line 1, in
File "/prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/pyplot.py", line 98, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/backends/init.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 38, in
from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg
ImportError: /prod/home/alok/cythontest/lib/python2.6/site-packages/matplotlib-1.3.0-py2.6-linux-x86_64.egg/matplotlib/backends/_backend_agg.so: undefined symbol: MPL_matplotlib__path_ARRAY_API

The MPL_matplotlib__path_ARRAY_API symbol is defined in _path.so file,
but is undefined in backends/_backend_agg.so:

$ nm backends/_backend_agg.so | grep ARRAY_API
U MPL_matplotlib__path_ARRAY_API
000776c0 B MPL_matplotlib_backends__backend_agg_ARRAY_API
00014280 t _GLOBAL__I_MPL_matplotlib_backends__backend_agg_ARRAY_API

I am not sure why _backend_agg.so is referring to
MPL_matplotlib__path_ARRAY_API. On a more modern system (Linux Mint 13),
the output from the above command is:

000000000026b438 B MPL_matplotlib_backends__backend_agg_ARRAY_API

I built matplotlib with the following:

$ python setup.py build
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Extracting in /tmp/tmp6y4XL0
Now working in /tmp/tmp6y4XL0/distribute-0.6.28
Building a Distribute egg in /prod/home/alok/Downloads/matplotlib-1.3.1

/prod/home/alok/Downloads/matplotlib-1.3.1/distribute-0.6.28-py2.6.egg

Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
matplotlib: yes [1.3.1]
python: yes [2.6.4 (r264:75706, Apr 12 2012, 06:55:25) [GCC
4.1.2 20080704 (Red Hat 4.1.2-46)]]
platform: yes [linux2]

REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.8.0]
dateutil: yes [using dateutil version 1.5]
tornado: yes [tornado was not found. It is required for the
WebAgg backend. pip/easy_install may attempt to
install it after matplotlib.]
pyparsing: yes [matplotlib requires pyparsing >= 1.5.6]
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 9.10.3]
png: yes [version 1.2.10]

OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: yes [using nose version 0.11.1]

OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt4agg: no [PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: yes [installing, version 73770]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairo not found]
windowing: no [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
dvipng: yes [version 1.5]
ghostscript: yes [version 8.70]
latex: yes [version 3.141592]
pdftops: no

Other information:

$ gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ python -V
Python 2.6.4
$ python -c 'import numpy; print numpy.version'
1.3.0

Am I doing something wrong?


Reply to this email directly or view it on GitHubhttps://github.com//issues/2577
.

|/|o | . _ | | ._ ||| _ _ ._ _
| ||(| |(|(/| |/|()(/|_ ||)()()| | |

http://www.droettboom.com/

@gandalf013
Copy link
Author

Sorry, that was a wrong cut-paste from a different terminal window. I do have numpy 1.3.0 (system numpy). I have installed numpy 1.8.0 separately in a subdirectory under my home directory. The output from python -c 'import numpy; print numpy.__version__' was taken from the wrong session where I hadn't fixed my PYTHONPATH properly.

The correct output is:

$ python -c 'import numpy; print numpy.__version__'
1.8.0

I just re-tested everything and the undefined symbol error still exists in the environment with numpy 1.8.0 and matplotlib 1.3.1. (Also, the REQUIRED DEPENDENCIES AND EXTENSIONS section of the matplotlib build output shows numpy 1.8.0.)

I have updated the original comment.

@gandalf013
Copy link
Author

Some more information:

I noticed that the class BackendAgg in setupext.py has 3 source files: src/mplutils.cpp, src/agg_py_transforms.cpp, src/_backend_agg.cpp. I noticed that src/agg_py_transforms.cpp is also a part of Path class. So my guess is that src/agg_py_transforms.cpp is being compiled with MPL_matplotlib__path_ARRAY_API as the unique numpy symbol.

Then, the building of _backend_agg.so extension via BackendAgg re-uses the agg_py_transforms.o file generated from the earlier step. This ends up having references to MPL_matplotlib__path_ARRAY_API in the _backend_agg.so module as well.

I tried compiling matplotlib with python setup.py build --force from a clean source directory, and that results in each extension module's sources being re-compiled every time. With that option, I get everything to work properly.

I am not completely sure that this is the correct way to do this or if some distutils command should be used in setupext.py to re-compile the files needed automatically.

@mdboom
Copy link
Member

mdboom commented Nov 4, 2013

Do you have to use --force on subsequent times? I just do setup.py build install as a matter of course, and I've never run into this, but I could see how it might happen in a compilation is aborted and then restarted...

@gandalf013
Copy link
Author

I needed to specify --force on a clean directory (extracted from the .tar.gz archive downloaded from sourceforge). There was no build failure prior to this.

In short, this works:

$ tar xvf matplotlib-1.3.1.tar.gz
$ cd matplotlib-1.3.1
$ python setup.py build --force
$ python setup.py install

This doesn't (fails with "undefined symbol" error):

$ tar xvf matplotlib-1.3.1.tar.gz
$ cd matplotlib-1.3.1
$ python setup.py build # note, no --force
$ python setup.py install

@flamingbear
Copy link

I won't go to far, but to say "me too". I didn't test building the tarball with --force. Just dropped back to 1.1.1 for the time being. If you want more info, please ask.

Linux snow 2.6.27.54-0.2-default #1 SMP 2010-10-19 18:40:07 +0200 x86_64 x86_64 x86_64 GNU/Linux

@ghost ghost assigned mdboom Nov 11, 2013
@m3o7
Copy link

m3o7 commented Dec 9, 2013

@gandalf013 Thanks for sharing - --force worked for me as well!

@mdboom
Copy link
Member

mdboom commented Dec 10, 2013

Interesting. It's nice to have a "solution", but I'm not sure why the timestamps are funny in the first place...

@rlmarco
Copy link

rlmarco commented Jan 2, 2014

I had the same problem, and the --force option worked for me. Thanks.

@tacaswell tacaswell modified the milestones: v1.4.0, v1.3.x, v1.4.x Apr 17, 2014
@tacaswell tacaswell modified the milestones: 1.5.0, v1.4.x Feb 7, 2015
@tacaswell
Copy link
Member

@flamingbear @rlmarco @gandalf013 Can any of you still reproduce this issue with either 1.4.3rc1 or current master?

@flamingbear
Copy link

@tacaswell I can't reproduce the problem with the release candidate following @gandalf013 instructions. It's been so long that I can't remember how I was doing it before, but I started a virtualenv on the same machine as I reported the problem before.
Linux snow 2.6.27.54-0.2-default #1 SMP 2010-10-19 18:40:07 +0200 x86_64 x86_64 x86_64 GNU/Linux

and these commands didn't give me an error.

$ tar xvf matplotlib-1.3.1.tar.gz
$ cd matplotlib-1.3.1
$ python setup.py build # note, no --force
$ python setup.py install
(test)savoie@snow ~/tmp/test-mpl/matplotlib-1.4.3rc1$ pip freeze
matplotlib==1.4.3rc1
mock==1.0.1
nose==1.3.4
numpy==1.9.1
pyparsing==2.0.3
python-dateutil==2.4.0
pytz==2014.10
six==1.9.0
wsgiref==0.1.2

So that looks good to me.

@tacaswell
Copy link
Member

@flamingbear Thanks for checking!

Closing this. If anyone can still reproduce this please ping to have it re-opened.

@gandalf013
Copy link
Author

@flamingbear @tacaswell I can't get the master branch to build on Red Hat 5 because of old freetype. By the way, the problem was not with installing matplotlib, but while doing import matplotlib.pyplot as plt after the install. I just checked, and that problem is still there with version 1.3.1. But I think it's fine to keep this bug closed since I doubt many people will be installing the latest matplotlib on a RH5 system.

@flamingbear
Copy link

Bummer, that's what I get for not re-reading all of the thread. I also have generally moved from SLES 11.
Sorry for the false hope, but yes, I get the same error as before, but if I include the --force on the build, I do get a working version.

without --force:

savoie@snow ~/tmp/test-mpl$ . test/bin/activate
(test)savoie@snow ~/tmp/test-mpl$ python
Python 2.6 (r26:66714, Oct 28 2010, 20:58:09)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/sharehome/savoie/tmp/test-mpl/test/lib/python2.6/site-packages/matplotlib-1.4.3rc1-py2.6-linux-x86_64.egg/matplotlib/pyplot.py", line 109, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/sharehome/savoie/tmp/test-mpl/test/lib/python2.6/site-packages/matplotlib-1.4.3rc1-py2.6-linux-x86_64.egg/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/sharehome/savoie/tmp/test-mpl/test/lib/python2.6/site-packages/matplotlib-1.4.3rc1-py2.6-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 13, in <module>
    import matplotlib.backends.tkagg as tkagg
  File "/sharehome/savoie/tmp/test-mpl/test/lib/python2.6/site-packages/matplotlib-1.4.3rc1-py2.6-linux-x86_64.egg/matplotlib/backends/tkagg.py", line 7, in <module>
    from matplotlib.backends import _tkagg
ImportError: /sharehome/savoie/tmp/test-mpl/test/lib/python2.6/site-packages/matplotlib-1.4.3rc1-py2.6-linux-x86_64.egg/matplotlib/backends/_tkagg.so: undefined symbol: MPL_matplotlib__path_ARRAY_API
>>>

with --force

savoie@snow ~/tmp/test-mpl$ . test/bin/activate
(test)savoie@snow ~/tmp/test-mpl$ python
Python 2.6 (r26:66714, Oct 28 2010, 20:58:09)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants