3

I have a trouble while importing matplotlib in PyCharm4.5.3

from pylab import *`

Error:

Traceback (most recent call last):
  File "/home/vera/PycharmProjects/COM/backend/17.08", line 10, in <module>

    from pylab import *

  File "/usr/lib/python3/dist-packages/pylab.py", line 1, in <module>

from matplotlib.pylab import *

  File "/usr/lib/python3/dist-packages/matplotlib/pylab.py", line 226, in <module>

import matplotlib.finance

  File "/usr/lib/python3/dist-packages/matplotlib/finance.py", line 21, in <module>

from matplotlib.dates import date2num

  File "/usr/lib/python3/dist-packages/matplotlib/dates.py", line 119, in <module>


     from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
      File "/usr/lib/python3/dist-packages/dateutil/rrule.py", line 55
        raise ValueError, "Can't create weekday with n == 0"
                    ^
SyntaxError: invalid syntax

Process finished with exit code 1

It was working before I installed PyCharm Community Edition. In professional edition it worked. But after installation the programm broked even in PyCharm professional Edition.

What i did wrong?

3 Answers 3

8

I also had the same problem while using matplotlib in anaconda virtual environment. Updating the dateutil lib to the latest version worked for me :

pip install python-dateutil --upgrade

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

It works for me when I was using python 3.5.3 in virtual env.
2

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

Maybe you installed an old version of dateutil?

1 Comment

Check if you have dateutil version <= 1.5.x installed. If yes, then you should install a >= 2.x version.
0

I had the same problem and solved it reinstalling the python-dateutil library:

pip3 uninstall python-dateutil
pip3 install python-dateutil

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.