python

import matplotlib.pyplot as plt

报错


zzzz@zzzz-virtual-machine:~$ python show.py

Traceback (most recent call last):

  File “show.py”, line 1, in

    import matplotlib.pyplot as plt

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py”, line 39, in

    from matplotlib.figure import Figure, figaspect

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/matplotlib/figure.py”, line 40, in

    from matplotlib.axes import Axes, SubplotBase, subplot_class_factory

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/matplotlib/axes/init.py”, line 4, in

    from ._subplots import *

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_subplots.py”, line 10, in

    from matplotlib.axes._axes import Axes

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py”, line 24, in

    import matplotlib.dates as _  #

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/matplotlib/dates.py”, line 152, in

    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,

  File “/home/zzzz/anaconda3/lib/python3.6/site-packages/dateutil/rrule.py”, line 55

    raise ValueError, “Can’t create weekday with n 0″

                    ^

SyntaxError: invalid syntax


原因:The file rrule.py from the dateutil module uses old (invalid) syntax to raise an exception.

因为dateutil版本太旧

解决方案:

安装新版本python-dateutil 

首先卸载原有旧版本 再进行安装

pip uninstall python-dateutil

pip install python-dateutil

之后再次运行程序即可

文章来源于互联网,如有雷同请联系站长删除:import matplotlib报错:raise ValueError, “Can’t create weekday with n 0″

发表评论