Python - 在matplotlib raindrop示例中导入错误

时间:2015-09-07 21:00:49

标签: python matplotlib

我正在尝试在我的Python 2.7.10 IDLE(在Mac上运行,OS X 10.10.5)上使用matplotlib(版本1.4.3)运行Nicolas Rougier's raindrop animation但是我得到以下内容导入错误:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
....
    from matplotlib import pyplot as plt
  File "/Library/Python/2.7/site-packages/matplotlib/pyplot.py", line 34, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 40, in <module>
    from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
  File "/Library/Python/2.7/site-packages/matplotlib/axes/__init__.py", line 4, in <module>
    from ._subplots import *
  File "/Library/Python/2.7/site-packages/matplotlib/axes/_subplots.py", line 10, in <module>
    from matplotlib.axes._axes import Axes
  File "/Library/Python/2.7/site-packages/matplotlib/axes/_axes.py", line 21, in <module>
    import matplotlib.dates as _  # <-registers a date unit converter
  File "/Library/Python/2.7/site-packages/matplotlib/dates.py", line 126, in <module>
    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
  File "/Library/Python/2.7/site-packages/dateutil/rrule.py", line 16, in <module>
    from six.moves import _thread
ImportError: cannot import name _thread

我使用的脚本与链接中的脚本完全相同,但我必须在import matplotlibmatplotlib.use('TKAgg') import语句之前插入语句pyplotFuncAnimation顶部。

1 个答案:

答案 0 :(得分:2)

您需要为python重新安装dateutil包。

sudo pip uninstall dateutil
sudo pip install python-dateutil==2.2