'FigureCanvasTkAgg' object has no attribute 'update'

6,343 views
Skip to first unread message

Kevin Shen

unread,
Mar 3, 2016, 2:58:05 AM3/3/16
to gps-help
Hi there,

I am just trying to run the first example with 2dBox. After installing the dependencies, I ran the example and it crashes with the error:

File "python/gps/gui/output_axis.py", line 68, in draw
    self._fig.canvas.update()
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update

Did I miss something in setting up the dependencies?

Thanks in advance!

Ashvin Nair

unread,
Mar 3, 2016, 9:56:59 PM3/3/16
to gps-help
I found I had to switch all the

self._fig.canvas.update()

lines to

self._fig.canvas.draw()

and then it worked. Maybe a version mismatch?

Chelsea Finn

unread,
Mar 3, 2016, 10:20:30 PM3/3/16
to Ashvin Nair, gps-help
Can you try adding "matplotlib.use('Qt4Agg')" right below "import matplotlib" in target_setup_gui.py and gps_training_gui.py?

​- Chelsea​


--
You received this message because you are subscribed to the Google Groups "gps-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gps-help+u...@googlegroups.com.
To post to this group, send email to gps-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gps-help/388ec811-539b-4c1c-b168-69c54df062c9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Kevin Shen

unread,
Mar 3, 2016, 10:41:57 PM3/3/16
to gps-help
Thanks! That fixed it! Although I'm thinking .draw() may slow the program down a bit compared to .update()?

Kevin Shen

unread,
Mar 3, 2016, 10:57:37 PM3/3/16
to gps-help
Hi Chelsea,

Thanks for your reply! Ashvin's suggestion worked. However, I tried your suggestion as well. It doesn't look like target_setup_gui.py or gps_training_gui.py imports the entire matplotlib library, so when I add "matplotlib.use('Qt4Agg')", matplotlib is not recognized as a variable. I added "import matplotlib as matplotlib" but it now complains

UserWarning:  This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

Would there be any reason to not go with Ashvin's fix?

Kevin

Chelsea Finn

unread,
Mar 3, 2016, 11:16:26 PM3/3/16
to Kevin Shen, gps-help, Dennis Tan
Ok, I'm not sure -- I'm CC'ing Dennis, who wrote all of the GUI code.

Dennis - see below. Is replacing update() with draw() the best solution? Or is there a better solution?

Chelsea

Ashvin Nair

unread,
Mar 4, 2016, 6:05:17 PM3/4/16
to gps-help
I found 

import matplotlib
matplotlib.use('Qt4Agg')

also works but you have to put it above the imports for pyplot and other matplotlib modules as the error says.

Chelsea Finn

unread,
Mar 4, 2016, 6:06:32 PM3/4/16
to Ashvin Nair, gps-help
Ok. I'll push a fix to the master branch soon.

Chelsea Finn

unread,
Mar 5, 2016, 7:37:09 PM3/5/16
to Ashvin Nair, gps-help
Dennis just pushed a fix.

Chelsea
Reply all
Reply to author
Forward
0 new messages