Tkinter 导致 SIGSEGV 和系统崩溃 - 如何修复?

Tkinter causes SIGSEGV and system crash - how to fix?(Tkinter 导致 SIGSEGV 和系统崩溃 - 如何修复?)
本文介绍了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 和系统崩溃 - 如何修复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Multiprocessing on Windows breaks(Windows 上的多处理中断)
How to use a generator as an iterable with Multiprocessing map function(如何将生成器用作具有多处理映射功能的可迭代对象)
read multiple files using multiprocessing(使用多处理读取多个文件)
Why does importing module in #39;__main__#39; not allow multiprocessig to use module?(为什么在__main__中导入模块不允许multiprocessig使用模块?)
Trouble using a lock with multiprocessing.Pool: pickling error(使用带有 multiprocessing.Pool 的锁时遇到问题:酸洗错误)
Python sharing a dictionary between parallel processes(Python 在并行进程之间共享字典)