error in sys.exitfunc
我在使用 matplotlib 时不断得到。例如,以下代码将它用于 matplotlib 1.3.0 / Python 2.7.3 / Ubuntu 12.04.3 LTS
from matplotlib.pyplot import figure, show
from numpy.random import random
fh = figure(figsize = (15, 10, ))
ax = fh.add_axes((.1, .1, .8, .8, ))
ax.scatter(random((100, )), random((100, )))
fh.show()
这产生
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/_pylab_helpers.py", line 86, in destroy_all
manager.destroy()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py", line 427, in destroy
self.canvas.destroy()
AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/_pylab_helpers.py", line 86, in destroy_all
manager.destroy()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py", line 427, in destroy
self.canvas.destroy()
AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
这种情况发生在程序在没有 的情况下终止的任何时候show()
,包括引发不相关的错误时。
如果我使用show()
而不是fh.show()
,我不会收到此错误。我可以这样做,但是这个错误在很多地方都会弹出,我更愿意解决它(我希望能够在不显示数字的情况下退出)。
我尝试了其他不可用、没有显示或给出相同错误的后端(这是 GKT3Agg)。