0

This is my error traceback:

Traceback (most recent call last):
  File "D:\My projects\aaa.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\SHREYANSH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\matplotlib\__init__.py", line 138, in <module>
    from . import cbook, rcsetup
  File "C:\Users\SHREYANSH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\matplotlib\rcsetup.py", line 28, in <module>
    from cycler import Cycler, cycler as ccycler
  File "C:\Users\SHREYANSH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\cycler.py", line 46, in <module>
    import six
  File "D:\My projects\six.py", line 2, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\SHREYANSH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\matplotlib\pyplot.py", line 30, in <module>
    from cycler import cycler
ImportError: cannot import name 'cycler' from 'cycler' (C:\Users\SHREYANSH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\cycler.py)

I tried it after reinstalling matplotlib but nothing works please help.

Sanip
  • 1,772
  • 1
  • 14
  • 29
  • 1
    One problem is that you have a file called `six.py` in your folder. Don't call a file by the same name as a python module. – ImportanceOfBeingErnest Jul 18 '19 at 09:54
  • the problem is because _your_ `six.py` is trying to import `cycler` through `matplotlib`, but `cycler` needs to import _system package_ `six.py` too, but it sees that your `six` is already there so it does imports. And what we got here is, _your own_ `six` import itself, which causes the import-looping problem. see [this link](https://stackoverflow.com/questions/11698530/two-python-modules-require-each-others-contents-can-that-work). you should rename _your_ `six.py` to something else. – AcaNg Jul 18 '19 at 12:35

3 Answers3

3

Ouch! I found out what was happening. I was naming my sample work as one, two, three, etc. and I also had a file "six.py". Make sure you don't have a file named six.py in your path.

0

In my case it was a privilege problem, I have uninstall cycler and matplotlib by:

sudo pip uninstall cycler matplotlib

and than install them again with:

pip3 install matplotlib

and it works fine, I hope that could help.

Walid Bousseta
  • 1,329
  • 2
  • 18
  • 33
-2

Try to install 'cycler' then install 'matplotlib'

pip install cycler
pip install matplotlib
Rahul Verma
  • 2,988
  • 2
  • 11
  • 26