导入matplotlib.pyplot不起作用

iRo*_*biv 5 macos matplotlib importerror

我是python的新手,只是尝试进行所有设置。我尝试重新安装,但在尝试“将matplotlib.pyplot导入为plt”时仍然出现错误,有人知道这意味着什么吗?

 Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 16, in <module>
import artist
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so, 2): no suitable image found.  Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so: no matching architecture in universal wrapper
Run Code Online (Sandbox Code Playgroud)

谢谢!

cos*_*sis 1

在多个 Mac 操作系统上安装 python 和 matplotlib 时,我遇到了类似的问题。我最终做的是使用 Python2.6 重新安装并获取兼容的包。我花了一些时间才弄清楚哪种组合适用于哪种架构,但最终我让一切都可以运行。

matplotlib 网站甚至提到了这些问题:

“OSX 上的构建情况很复杂,因为可以从(darwinports、fink、/usr/X11R6)获取 png 和 freetype 要求的各个地方、不同的体系结构(x86、ppc、universal)以及不同的 OSX 版本(10.4 和10.5)。”