本文介绍了在Mac OSX 10.6上的python 2.7中导入matplotlib.mlab和.pyplot时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 OSX 10.6 上的 Python 2.7 中使用 matplotlib 绘制直方图

I am trying to plot a histogram using matplotlib in Python 2.7 on OSX 10.6

我已经验证我可以将 numpy、scipy 和 matplotlib 导入到 python 中.matplotlib 网站上的示例脚本可以

I have verified that I can import numpy, scipy, and matplotlib into python. A sample script on the matplotlib website does

#!/usr/bin/env python
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

但是,执行此操作时出现错误.这是我尝试导入mlab时发生的情况.

However, I get an error when doing this. Here is what happens when I try to import mlab.

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.mlab as mlab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mlab.py", line 151, in <module>
    import matplotlib.nxutils as nxutils
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/nxutils.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/nxutils.so: no matching architecture in universal wrapper
>>>

我做错了什么,我不能像脚本那样导入这些?

What am I doing wrong that I can't import these as the script does?

推荐答案

我认为最好的选择是使用您拥有的 Python.说明此处.

I think the best option is to use the Python you have. Instructions here.

这篇关于在Mac OSX 10.6上的python 2.7中导入matplotlib.mlab和.pyplot时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:04