Tkinter causes SIGSEGV and system crash - how to fix?(Tkinter 导致 SIGSEGV 和系统崩溃 - 如何修复?)
问题描述
我正在为一个 python 项目开发一个 Tkinter GUI.昨天一切都很好,但是今天当我运行 mainloop()
命令时,我的 mac 立即崩溃(返回登录屏幕).
I'm developing a Tkinter GUI for a python project. Everything was fine yesterday, but today my mac immediately crashes (back to log-in screen) when I run the mainloop()
command.
我试图通过减少 GUI 功能来隔离问题,但没有任何帮助.即使是最简单的 GUI 也会出现问题.
I've tried to isolate the issue by cutting back GUI features, but nothing helped. The problem even occurs with the simplest of GUIs.
我正在使用这个演示代码:
I'm using this demo code:
from tkinter import Tk, Label, Button
class MyFirstGUI:
def __init__(self, master):
self.master = master
master.title("A simple GUI")
root = Tk()
my_gui = MyFirstGUI(root)
root.mainloop()
当我运行最后一行时,我的屏幕会变黑一秒钟并返回 MacOS 登录屏幕.从终端运行脚本时也会发生.重复几次后,我发现在每次崩溃后,system.log 中都会出现这一行:
When I run the last line, my screen goes black for a second and returns the MacOS log-in screen. Also happens when running the script from terminal. After a few repeats, I found this line to recur in the system.log after at each crash:
Jul 29 17:58:51 MacBook-Pro-myname com.apple.xpc.launchd[1] (com.apple.WindowServer[1510]): Service exited due to SIGSEGV | sent by exc handler[1510]
每次崩溃的处理程序编号都是唯一的.以安全模式启动可以解决问题,但我当然不能永远处于安全模式:)
The handler number is unique to each crash. Booting in Safe Mode resolves the issue, but of course I cannot live in Safe Mode forever :)
这似乎是某种内部问题,因为 python 代码再简单不过了.我不知道如何调试这个,谁能帮帮我?
It seems some sort of internal issue, as the python code could not be simpler. I have no clue how to debug this, can anyone help me out?
已修复 - 出于某种原因,Tkinter 开始弄乱我的机器.更新到 8.6.9 解决了这个问题.(参见:https://bugs.python.org/issue34927)
FIXED IT - For some reason Tkinter started to mess with my machine. Update to 8.6.9 resolved the issue. (see: https://bugs.python.org/issue34927)
推荐答案
结果由于某种原因标准版本的 Tkinter (8.6.*) 不再正常运行.我发现 https://bugs.python.org/issue34927 并很快更新到 Tkinter 8.6.9(conda forge),这似乎已经解决了这个问题.
Turns out for some reason the standard version of Tkinter (8.6.*) was no longer functioning correctly. I found https://bugs.python.org/issue34927 and soon after updated to Tkinter 8.6.9 (conda forge), which seems to have solved the issue.
这篇关于Tkinter 导致 SIGSEGV 和系统崩溃 - 如何修复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Tkinter 导致 SIGSEGV 和系统崩溃 - 如何修复?
基础教程推荐
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 筛选NumPy数组 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01