問題描述
我正在為一個 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 和系統崩潰 - 如何修復?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!