import matplotlib.pyplot 错误

错误描述

import matplotlib.pyplot时可能出现以下错误:

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brown/anaconda/lib/python3.6/site-packages/matplotlib/pyplot.py", line 37, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/Users/brown/anaconda/lib/python3.6/site-packages/matplotlib/figure.py", line 40, in <module>
    from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
  File "/Users/brown/anaconda/lib/python3.6/site-packages/matplotlib/axes/__init__.py", line 4, in <module>
    from ._subplots import *
  File "/Users/brown/anaconda/lib/python3.6/site-packages/matplotlib/axes/_subplots.py", line 10, in <module>
    from matplotlib.axes._axes import Axes
  File "/Users/brown/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 24, in <module>
    import matplotlib.dates as _  # <-registers a date unit converter
  File "/Users/brown/anaconda/lib/python3.6/site-packages/matplotlib/dates.py", line 125, in <module>
    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
  File "/Users/brown/anaconda/lib/python3.6/site-packages/dateutil/rrule.py", line 55
    raise ValueError, "Can't create weekday with n == 0"
                    ^
SyntaxError: invalid syntax

错误分析解决

来自datautil模块的文件rrule.py使用了旧的语法,所以报异常。检查你安装的datautil模块版本是否<= 1.5.x,如果是的话,请使用以下命令升级此模块:

pip install python-dateutil --upgrade


Ref
http://stackoverflow.com/questions/32079919/trouble-with-importing-matplotlib

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值