Opened 9 years ago

Closed 9 years ago

#50065 closed defect (invalid)

py-matplotlib: Problem with import matplotlib.pyplot : RuntimeError: module compiled against API version a but this version of numpy is 9

Reported by: phillicl@… Owned by: seanfarley (Sean Farley)
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: Cc:
Port: py-matplotlib

Description

Somehow the matplotlib port has been compiled against the wrong version of numpy.

(This problem started after I did port install py27-pandas )

import matplotlib.pyplot

generates the error

RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
    import matplotlib.artist as martist
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 14, in <module>
    from .transforms import (Bbox, IdentityTransform, TransformedBbox,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
    from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import

Some attempts to reinstall matplotlib, numpy, and scipy have not resolved the problem

Change History (6)

comment:1 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: changed from macports-tickets@… to sean@…
Port: py-matplotlib added
Summary: Problem with import matplotlib.pyplot : RuntimeError: module compiled against API version a but this version of numpy is 9py-matplotlib: Problem with import matplotlib.pyplot : RuntimeError: module compiled against API version a but this version of numpy is 9

comment:2 Changed 9 years ago by phillicl@…

I decided that the problem may be that despite the fact that I uninstalled and reinstalled numpy, that an old version of numpy (1.9.3) was still hanging around and being imported each time numpy was used.

So I uninstalled py27-numpy, cleaned that directory, and rebuilt everything.

Indeed now I get which python /opt/local/bin/python

import numpy

numpy.version

'1.10.1'

numpy.path

opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy?

However, now when I import matplotb.pyplot, the import just hangs.....

When I kill the import, its always hanging in the same place

  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
    import matplotlib.collections as collections
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
    import matplotlib.backend_bases as backend_bases
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 62, in <module>
    import matplotlib.textpath as textpath
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/textpath.py", line 15, in <module>
    import matplotlib.font_manager as font_manager
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1420, in <module>
    _rebuild()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1405, in _rebuild
    fontManager = FontManager()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1043, in __init__
    self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 323, in findSystemFonts
    for f in get_fontconfig_fonts(fontext):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py", line 276, in get_fontconfig_fonts
    output = pipe.communicate()[0]
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 799, in communicate
    return self._communicate(input)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1409, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1463, in _communicate_with_poll
    ready = poller.poll()

comment:3 Changed 9 years ago by seanfarley (Sean Farley)

Did you install any python packages in your system python? Or anything in /usr/local?

comment:4 Changed 9 years ago by phillicl@…

I always use the macport python.

However, I think I used pip install to install tensorflow. Perhaps that initiated the depedency problem where the path to my system's numpy package because the first found.

(I read that the first time matplotlib.pyplot is called, it may just need to run for a while. I let it do this and the problem resolved.)

comment:5 Changed 9 years ago by phillicl@…

From their website

Pip install: Install TensorFlow on your machine, possibly upgrading previously installed Python packages. May impact existing Python programs on your machine.

So... that is probably what happened

comment:6 Changed 9 years ago by seanfarley (Sean Farley)

Resolution: invalid
Status: newclosed

Yep. You can't use pip outside of a virtualenv with any package manager, really.

Note: See TracTickets for help on using tickets.