我正在尝试在我的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 matplotlib
和matplotlib.use('TKAgg')
import语句之前插入语句pyplot
和FuncAnimation
顶部。
答案 0 :(得分:2)
您需要为python重新安装dateutil包。
sudo pip uninstall dateutil
sudo pip install python-dateutil==2.2