小编典典

OS X上的Matplotlib问题(“ ImportError:无法导入名称_thread”)

python

在最近几天的某个时候,Matplotlib停止在OS X上为我工作。这是我尝试执行import matplotlib以下操作时遇到的错误:

Traceback (most recent call last):
  File "/my/path/to/script/my_script.py", line 15, in <module>
    import matplotlib.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 22, 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 14, in <module>
    from six.moves import _thread
ImportError: cannot import name _thread

我能想到的唯一的系统更改是Apple强制的NTP更新,也许我在/ usr / local中进行了一些权限更改,以使Brew重新工作。

我尝试通过Pip重新安装Matplotlib和Python-dateutil,但这没有帮助。还尝试了重启。我正在运行Python 2.7.6,它位于/
usr / bin / python中。我正在运行优胜美地(OS X 10.10.1)。


阅读 267

收藏
2020-12-20

共1个答案

小编典典

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

尽管我最近升级到优胜美地,但今天下午我也收到了同样的错误消息。我不太确定我是否理解为什么将dateutil还原到以前的版本对我有用,但是由于运行上述命令,我没有任何麻烦(我通常在ipython笔记本中使用pyplot
inline)。

2020-12-20