Problem importing matplotlib.mlab and .pyplot in python 2.7 on Mac OSX 10.6

走远了吗. 提交于 2019-12-01 19:47:41

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

For the ImportError: It seems that there is an architecture mismatch. Maybe you have installed a 32-bit version of matplotlib, but are using a 64-bit Python? What does the following shell command print?

file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/nxutils.so

For the AttributeError: You have to explicitely import matplotlib.pyplot, it won't get imported automatically when just importing matplotlib. The most common aliasing scheme is:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

Then you can draw your histogram using the plt name:

plt.hist(...)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!