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

前端 未结 2 1900
旧巷少年郎
旧巷少年郎 2021-01-19 11:14

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

I have verified that I can import numpy, scipy, and matplotlib into python. A sample scrip

相关标签:
2条回答
  • 2021-01-19 11:42

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

    0 讨论(0)
  • 2021-01-19 11:52

    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(...)
    
    0 讨论(0)
提交回复
热议问题