安装matplotlib的时候可能会出现输入import matplotlib.pyplot as plt出现报错的现象,如下图所示:
>>> import matplotlib
>>> import numpy
>>> import scipy
>>> import pyparsing
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\Lib\site-packages\matplotlib\pyplot.py", line 29, in <module>
from matplotlib.figure import Figure, figaspect
File "C:\Python27\Lib\site-packages\matplotlib\figure.py", line 36, in <module>
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
File "C:\Python27\Lib\site-packages\matplotlib\axes.py", line 20, in <module>
import matplotlib.dates as _ # <-registers a date unit converter
File "C:\Python27\Lib\site-packages\matplotlib\dates.py", line 119, in <module>
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
File "C:\Python27\Lib\site-packages\dateutil\rrule.py", line 18, in <module>
from six import advance_iterator, integer_types
ImportError: No module named six
解决办法是:
把路径如:C:\Python27\Lib\site-packages\scipy\lib中的six.py six.pyc six.pyo三个文件拷贝到C:\Python27\Lib\site-packages目录下。
再在IDLE(Python GUI)中输入import matplotlib.pyplot as plt便可以解决啦!
如下所示:
>>> import matplotlib.pyplot as plt
>>>