简体   繁体   中英

Error: from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' (C:\\Garden\lib\site-packages\matplotlib\__init__.py)

I want work with garden.matplotlib.FigureCanvas , but I get every time same problem. I install matplotlib , garden and kivy (separate). All the Library installs work, except matplotlib.backend_kivyagg .
I downloaded a file from kivy for testing ( https://github.com/kivy-garden/garden.matplotlib ). Here the Error:

-----------------------------------------------------------------------------------   
Traceback (most recent call last):
   File "C:/Users/alidi/OneDrive/Desktop/Garden/garden.matplotlib/garden.matplotlib-master/examples/test_backend.py", line 10, in <module>
     from kivy.garden.matplotlib.backend_kivyagg import FigureCanvas,\
   File "C:\Users\alidi\Desktop\Data_analysis_book_\Garden\lib\site-packages\kivy\garden\__init__.py", line 180, in load_module
     return self._load_module(fullname, moddir)
   File "C:\Users\alidi\Desktop\Data_analysis_book_\Garden\lib\site-packages\kivy\garden\__init__.py", line 183, in _load_module
     mod = imp.load_module(fullname, None, moddir,
   File "C:\Users\alidi\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 244, in load_module
     return load_package(name, filename)
   File "C:\Users\alidi\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 216, in load_package
     return _load(spec)
   File "C:\Users\alidi\.kivy\garden\garden.matplotlib\__init__.py", line 1, in <module>
     from kivy.garden.matplotlib.backend_kivy import FigureCanvasKivy,\
   File "C:\Users\alidi\.kivy\garden\garden.matplotlib\backend_kivy.py", line 256, in <module>
     from matplotlib import _png
 ImportError: cannot import name '_png' from 'matplotlib' (C:\Users\alidi\Desktop\Data_analysis_book_\Garden\lib\site-packages\matplotlib\__init__.py)

Process finished with exit code 1

Had the same problem with python 3.7, kivy==2.0.0, kivy-garden==0.1.4, matplotlib==3.4.1. Downgrading the matplotlib solved the problem:

pip install matplotlib==3.1.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM