matplotlib with kivy shows some error
Opened this issue · 7 comments
i am using kubuntu 18.04
python 3.6.9
matplotlib 3.3.1
installing method
pip3 install kivy_garden
garden install matplotlib
code:
from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
import matplotlib.pyplot as plt
plt.plot([1, 23, 2, 4])
plt.ylabel('some numbers')
class MyApp(App):
def build(self):
box = BoxLayout()
box.add_widget(FigureCanvasKivyAgg(plt.gcf()))
return box
MyApp().run()
log|:
python3 m.py
[INFO ] [Logger ] Record log in /home/sahil/.kivy/logs/kivy_20-08-18_43.txt
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "/usr/lib/python3/dist-packages/kivy/init.py"
[INFO ] [Python ] v3.6.9 (default, Jul 17 2020, 12:50:27)
[GCC 8.4.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python3"
Traceback (most recent call last):
File "m.py", line 1, in
from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg
File "/usr/lib/python3/dist-packages/kivy/garden/init.py", line 173, in load_module
return self._load_module(fullname, moddir)
File "/usr/lib/python3/dist-packages/kivy/garden/init.py", line 177, in _load_module
('', '', imp.PKG_DIRECTORY))
File "/usr/lib/python3.6/imp.py", line 245, in load_module
return load_package(name, filename)
File "/usr/lib/python3.6/imp.py", line 217, in load_package
return _load(spec)
File "/home/sahil/.kivy/garden/garden.matplotlib/init.py", line 1, in
from kivy.garden.matplotlib.backend_kivy import FigureCanvasKivy,
File "/home/sahil/.kivy/garden/garden.matplotlib/backend_kivy.py", line 256, in
from matplotlib import _png
ImportError: cannot import name '_png'
The temporary solution is to downgrade matplotlib to 2.2.5:
pip uninstall matplotlib
pip install matplotlib==2.2.5
It seems to me that kivy.garden is incompatible with matplotlib 3.xx at all :-(
matplotlib version 3.2.1 working fine ..i have tested it.
Any news here? Matplotlib is now at 3.4.2 and many other modules require versions >3.3. which currently fails with Kivy due to this bug...
KivyGarden does not have a gardener, the flowers have bit rot.
Consider contributing....
I have not enough experience to contribute to this project. But if I understood correctly there is nothing more needed than commenting out the line where _png
is imported, then commit and deploy?