0

显示是模块:

import matplotlib
matplotlib.use('TkAgg')   #TkAgg is quite slow but should work on all platforms.

import time
import numpy
import matplotlib.pyplot as plt  

def display_2d_array(arr):
    '''Display a square 2D numpy array as a greyscale image.'''
    assert len(arr.shape) == 2 and arr.shape[0] == arr.shape[1]
    plt.ion()
    plt.clf()
    plt.imshow(arr,origin="lower",extent=[0,arr.shape[0],0,arr.shape[0]])
   plt.gray()
   plt.draw()
   raw_input('Hit enter to continue.')

但是当我在模块中调用它时,我得到:

File "/Users/tomkimpson/display.py", line 8, in <module>
import matplotlib.pyplot as plt  
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site                  packages/matplotlib/pyplot.py", line 26, 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 24, in <module>
import matplotlib.artist as martist
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 7, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, \
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
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

有人知道这意味着什么吗?!

4

1 回答 1

0

看起来你是在 OS X 上运行这个。看看这个这个问题,另一个 OS X 用户有同样的错误。您的 matplotlib 安装可能已损坏。有问题的标记答案链接到此页面,其中详细说明了如何在 OS X 上安装 matplotlib。

于 2012-12-11T20:25:52.313 回答