gscreen breaks with import matplot

More
4 years 2 months ago #248932 by thadwald
Hi

I am trying to use metplotlib for displaying a simple automated/guided CAM solution in gscreen (linuxcnc 2.8.2)

Following metplotlib tutorial, for using metplot with gtk2, I try the following line:
Code:
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas

gscreen fails with the following error:
Code:
2 Traceback (most recent call last):   File "/usr/bin/gscreen", line 4661, in <module>     app = Gscreen()   File "/usr/bin/gscreen", line 792, in __init__     self.initialize_widgets()   File "/usr/bin/gscreen", line 1086, in initialize_widgets     self.init_dro_colors()   File "/usr/bin/gscreen", line 1196, in init_dro_colors     self.widgets.abs_colorbutton.set_color(gtk.gdk.color_parse(self.data.abs_textcolor))   File "/usr/bin/gscreen", line 228, in __getattr__     if r is None: raise AttributeError, "No widget %r" % attr AttributeError: No widget 'abs_colorbutton'

I suspect that maybe the import statement references gtk3 libraries but this is just a guess.
Any suggestions?

Please Log in to join the conversation.

More
4 years 2 months ago #248933 by thadwald
I have also tried
Code:
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas

I get the same results

Please Log in to join the conversation.

More
4 years 2 months ago #248981 by andypugh
This looks like a funny one, maybe a namespace clash, for example.

Just as a check, if you comment-out the import matplot.... Does it all work again?

Please Log in to join the conversation.

More
4 years 2 months ago #248990 by thadwald
Yes. It works fine with the other matplot import. It appears to be the gtk one that causes the problem.

Please Log in to join the conversation.

More
4 years 2 months ago #248992 by cmorley
have you tried your import just in a python session?
Gscreen some times hides the real error.
Did you check the terminal or is that error from the dialog box?
The terminal usually shows more.

But I would confirm the library imports all by it's self first.
You can also wrap a try statement around it:
Code:
try:     from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas except Exception as detail:     print (detail)

then look in the terminal.

Please Log in to join the conversation.

More
4 years 2 months ago #248994 by thadwald
Thank you. There is actually an issue with the import statement and, like you said, gscreen was hiding it.

I have been running from terminal precisely to see these errors but this one didn't show up until explicitly trapped. 

Thanks again!

Please Log in to join the conversation.

More
4 years 2 months ago #249035 by thadwald
Follow-up
The root cause was that pip installs matplotlib by default without GTK C extensions.

using:
Code:
pip install matplotlib --no-binary=matplotlib

forces it to build the binaries, which then include the required GTK parts.

Please Log in to join the conversation.

Time to create page: 0.198 seconds
Powered by Kunena Forum