栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python保存图片三次后,第四次总是报错

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python保存图片三次后,第四次总是报错

python中使用import matplotlib.pyplot as plt的plt保存图片的时候,前三次总是没问题,第四次总是报错。

报错如下:

Exception ignored in: >
Traceback (most recent call last):
  File "C:PythonPython36libtkinter__init__.py", line 3507, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: >
Traceback (most recent call last):
  File "C:PythonPython36libtkinter__init__.py", line 3507, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: >
Traceback (most recent call last):
  File "C:PythonPython36libtkinter__init__.py", line 3507, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Tcl_AsyncDelete: async handler deleted by the wrong thread

解决办法:

# import matplotlib.pyplot as plt

import matplotlib

matplotlib.use('Agg')

from matplotlib import pyplot as plt

用下面的三行替换掉引用的一行即可

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/269127.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号