Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'animation' (matplotlib + python 3.8.5)

Why doesnt matplotlib imported with python 3.8.5 work?

Im running anaconda version 3 which is 64 bit. The error im getting is:

Matplotlib is installed with version 3.3.2:

Using cached matplotlib-3.3.2-cp38-cp38-win_amd64.whl (8.5 MB)

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Ana
conda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\mat
plotlib\__init__.py", line 139, in <module>
    from . import cbook, rcsetup
  File "C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\mat
plotlib\rcsetup.py", line 26, in <module>
    from matplotlib import animation, cbook
ImportError: cannot import name 'animation' from partially initialized module 'm
atplotlib' (most likely due to a circular import) (C:\Users\Administrator\AppDat
a\Roaming\Python\Python38\site-packages\matplotlib\__init__.py)
like image 504
Endre Moen Avatar asked Oct 05 '20 13:10

Endre Moen


2 Answers

I had the same Issue. The site packages did not have the folder for animation at matplotlib folder. I uninstalled matplotlib and force reinstalled to have the packages added to the library and fixed the issue

pip install matplotlib --force-reinstall --user

like image 134
Praveenrajan27 Avatar answered Oct 27 '22 16:10

Praveenrajan27


I had so many problems with matplotlib it was unreal. In the end, I managed to get it working by removing matplotlib completely from my virtual env and then reinstalling using conda install matplotlib. I don't know what the problem was in the end but everything seems to be working now as it should.

like image 29
B92 Avatar answered Oct 27 '22 17:10

B92