我想使用garden.matplotlib.FigureCanvas
,但每次遇到同样的问题。我安装了matplotlib
,garden
和kivy
(分开)。除matplotlib.backend_kivyagg
之外,所有库安装工作。
我从kivy
下载了一个文件进行测试(https://github.com/kivy-garden/garden.matplotlib)。
错误在这里:
-----------------------------------------------------------------------------------
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
答案 0 :(得分:1)
python 3.7 有同样的问题,kivy==2.0.0,kivy-garden==0.1.4,matplotlib==3.4.1。 降级 matplotlib 解决了问题:
pip install matplotlib==3.1.1