matplotlib在干净的numpy安装上失败

时间:2014-05-01 17:44:25

标签: python python-2.7 numpy matplotlib

我正在尝试在OpenSUSE 11.4上安装matplotlib

使用pip(成功)

清理Numpy的安装

然后清除matplotlib(成功)

的安装

然后当我跑

import matplotlib
matplotlib.test()

我得到了

RuntimeError: module compiled against API version 6 but this version of numpy is 4
RuntimeError: module compiled against API version 6 but this version of numpy is 4
...
...    
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEERuntimeError: module compiled against API version 6 but this version of numpy is 4
ES.............

然后是一堆错误,比如

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'test_agg')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/loader.py", line 400, in loadTestsFromName
    module = resolve_name(addr.module)
  File "/usr/local/lib/python2.7/site-packages/nose/util.py", line 321, in resolve_name
    obj = getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_agg'

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'test_arrow_patches')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/loader.py", line 400, in loadTestsFromName
    module = resolve_name(addr.module)
  File "/usr/local/lib/python2.7/site-packages/nose/util.py", line 321, in resolve_name
    obj = getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_arrow_patches'

最后

======================================================================
ERROR: test suite for <module 'matplotlib.tests' from '/usr/local/lib64/python2.7/site-packages/matplotlib/tests/__init__.pyc'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/suite.py", line 208, in run
    self.setUp()
  File "/usr/local/lib/python2.7/site-packages/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "/usr/local/lib/python2.7/site-packages/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "/usr/local/lib/python2.7/site-packages/nose/util.py", line 469, in try_run
    return func()
  File "/usr/local/lib64/python2.7/site-packages/matplotlib/tests/__init__.py", line 28, in setup
    from matplotlib.backends import backend_agg, backend_pdf, backend_svg
  File "/usr/local/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 27, in <module>
    from matplotlib.backend_bases import RendererBase,\
  File "/usr/local/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 50, in <module>
    import matplotlib.textpath as textpath
  File "/usr/local/lib64/python2.7/site-packages/matplotlib/textpath.py", line 14, in <module>
    from matplotlib.mathtext import MathTextParser
  File "/usr/local/lib64/python2.7/site-packages/matplotlib/mathtext.py", line 62, in <module>
    import matplotlib._png as _png
ImportError: numpy.core.multiarray failed to import

----------------------------------------------------------------------
Ran 50 tests in 9.038s

FAILED (SKIP=1, errors=37)
False

1 个答案:

答案 0 :(得分:0)

原来有人使用numpy而不是zypper安装pip(v 1.5),默认numpy版本为1.5而不是1.8(如由pip安装。不知不觉,他们安装到

/usr/local/lib64/python2.7/site-packages/numpy # PIP

/usr/lib64/python2.7/site-packages/numpy # Zypper