From ec8c15191b24fce1c11b02e6fa256a3ed0c512b2 Mon Sep 17 00:00:00 2001 From: "let5sne.win10" Date: Thu, 12 Feb 2026 23:09:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 --debug 参数生成带控制台的版本 - 便于诊断运行时错误 Co-Authored-By: Claude Opus 4.6 --- build_exe.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build_exe.py b/build_exe.py index 9def9df..75b03e5 100644 --- a/build_exe.py +++ b/build_exe.py @@ -2,15 +2,17 @@ """ 打包脚本 - 将桌面程序打包成独立可执行文件 使用方法: pip install pyinstaller && python build_exe.py + +调试版本: python build_exe.py --debug """ import subprocess import sys from pathlib import Path -PROJECT_ROOT = Path(__file__).parent +PROJECT_ROOT = Path(__file__).parent) -def build(): +def build(debug=False): """使用 PyInstaller 打包""" print("正在打包,请稍候...") @@ -24,13 +26,17 @@ def build(): "-m", "PyInstaller", "--name=信封信息提取系统", "--onefile", - "--windowed", "--clean", "--noconfirm", "--paths=src", - "src/desktop.py", ] + # 调试模式:显示控制台窗口,便于查看错误 + if not debug: + cmd.append("--windowed") + + cmd.append("src/desktop.py") + try: subprocess.run(cmd, check=True, cwd=str(PROJECT_ROOT)) print("-" * 50) @@ -54,4 +60,5 @@ def build(): if __name__ == "__main__": - build() + debug = "--debug" in sys.argv + build(debug=debug)