AttributeError: ‘NoneType‘ object has no attribute ‘set_cursor‘问题解决

环境

ubuntu18.04
python3

错误信息

Traceback (most recent call last):
  File "/home/w/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2973, in _wait_cursor_for_draw_cm
    self.set_cursor(cursors.WAIT)
  File "/home/w/.local/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3.py", line 542, in set_cursor
    self.canvas.get_property("window").set_cursor(cursord[cursor])
AttributeError: 'NoneType' object has no attribute 'set_cursor'

解决办法

import matplotlib
matplotlib.use('Agg')

版权声明:本文为yrwang_xd原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。