You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从命令行启动PySimpleGUI应用时出现Mac OS相关错误提示

解决PySimpleGUI在macOS 13.1下stderr输出补丁提示的问题

问题现象

运行简单PySimpleGUI应用时,stderr会输出以下提示信息:

Mac OS Version is 13.1 and patch enabled so applying the patch
Applyting Mac OS 12.3+ Alpha Channel fix. Your default Alpha Channel is now 0.99

复现代码:

#!/usr/bin/env python3

import PySimpleGUI as sg

sg.Window(title="Hello World", layout=[[]], margins=(100, 50)).read()

已尝试brew upgrade、重装Python/python-tk、重装PySimpleGUI,问题依旧。

问题原因

这并非错误,而是PySimpleGUI针对macOS 12.3+系统的Alpha通道兼容性问题自动应用补丁时的调试提示信息,库内部将这些信息输出到了stderr。

解决方法

方法1:启用PySimpleGUI的调试输出抑制选项

在创建窗口前调用sg.set_options(suppress_debug_output=True),可以关闭这类调试提示:

#!/usr/bin/env python3

import PySimpleGUI as sg

sg.set_options(suppress_debug_output=True)
sg.Window(title="Hello World", layout=[[]], margins=(100, 50)).read()

方法2:调整日志级别

PySimpleGUI内部使用logging模块输出这类信息,将日志级别设为WARNING及以上可以过滤掉INFO级别的提示:

#!/usr/bin/env python3

import logging
logging.basicConfig(level=logging.WARNING)

import PySimpleGUI as sg
sg.Window(title="Hello World", layout=[[]], margins=(100, 50)).read()

内容的提问来源于stack exchange,提问作者Asqwhy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 00:10:20