Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matplotlib with kivy shows some error #67

Open
Sahil-pixel opened this issue Aug 18, 2020 · 7 comments
Open

matplotlib with kivy shows some error #67

Sahil-pixel opened this issue Aug 18, 2020 · 7 comments

Comments

@Sahil-pixel
Copy link

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'

@lokapal
Copy link

lokapal commented Aug 20, 2020

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 :-(

@RobertFlatt
Copy link

#from matplotlib import _png
#from matplotlib import _path

seems to work

Dup of #58 ?

@Sahil-pixel
Copy link
Author

matplotlib version 3.2.1 working fine ..i have tested it.

@mschroen
Copy link

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...

@RobertFlatt
Copy link

KivyGarden does not have a gardener, the flowers have bit rot.

Consider contributing....

@mschroen
Copy link

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?

@Joshua-Douglas
Copy link

I just ran this on my example on my machine and confirmed that #75 fixed this issue.

We can close this issue. I'm not sure to ask - maybe @matham?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants