Sorry in advance for answering an old question but I came across a similar issue after installing Python 3.6.9 and matplotlib
via pip
on a machine running with a Linux distro. My intent was to be able to re-run old scripts which involved pyplot
after upgrading Python on said machine. While the scripts ran until completion and provided the expected output, I was always getting this warning:
/home/jefgrailet/.local/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3.py:195: Warning: Source ID 8 was not found when attempting to remove it
GLib.source_remove(self._idle_draw_id)
upon using the savefig()
method from pyplot
(I guess a similar problem would have occurred with the show()
method as well). The line mentioned in the warning corresponds to this method found in backend_gtk3.py
:
def destroy(self):
#Gtk.DrawingArea.destroy(self)
self.close_event()
if self._idle_draw_id != 0:
GLib.source_remove(self._idle_draw_id)
I looked up on the matplotlib GitHub to check if there was a more recent version of the same script or if this problem was known, and it turns out the current implementation of the method above only rely on the self.close_event()
instruction, i.e., the GLib.source_remove()
is unnecessary.
Therefore, I commented the last 2 lines in the code above and saved the changes. After making this edit, I could run my scripts without getting any warning. I hope this will help people encountering a similar problem.