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

MacOS Big Sur 11.7.1中Python 2.7意外退出问题求助

macOS Big Sur 11.7.1 下 Python 2.7 运行程序崩溃的解决办法

问题描述

从Mojave升级到Big Sur 11.7.1后,使用系统自带的Python 2.7运行之前正常的开源程序时,频繁弹出「Python quit unexpectedly」错误。崩溃报告显示崩溃根源在于Tk/Tcl组件初始化失败(调用栈中出现TkpInit、Tcl_Panic等关键报错)。

崩溃报告详情:

Process:               Python [2524]
Path:                  /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:            org.python.python
Version:               2.7.16 (2.7.16)
Build Info:            python-136120002000000~85
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Python [2524]
User ID:               501

Date/Time:             2022-11-11 21:48:37.126 -0500
OS Version:            macOS 11.7.1 (20G918)
Report Version:        12
Bridge OS Version:     7.0 (20P420)
Anonymous UUID:        663C906C-6BC6-2F86-96DE-84CD144E197F

Sleep/Wake UUID:       0C782A1F-2791-4232-BF34-C0B65502FFE3

Time Awake Since Boot: 3000 seconds
Time Since Wake:       2300 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff2041991e __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff204485bd pthread_kill + 263
2   libsystem_c.dylib               0x00007fff2039d406 abort + 125
3   Tcl                             0x00007fff6f0389a5 Tcl_PanicVA + 366
4   Tcl                             0x00007fff6f038a25 Tcl_Panic + 128
5   Tk                              0x00007fff6f138a8f TkpInit + 543
6   Tk                              0x00007fff6f0b86b0 0x7fff6f087000 + 202416
7   _tkinter.so                     0x000000010bda3bc4 Tcl_AppInit + 84
8   _tkinter.so                     0x000000010bda35a1 0x10bd9d000 + 26017
9   org.python.python               0x000000010baef77c PyEval_EvalFrameEx + 20840
10  org.python.python               0x000000010baea009 PyEval_EvalCodeEx + 533
11  org.python.python               0x000000010ba90f8e 0x10ba66000 + 176014
12  org.python.python               0x000000010ba7355e PyObject_Call + 97
13  org.python.python               0x000000010ba7de3c 0x10ba66000 + 97852
14  org.python.python               0x000000010ba7355e PyObject_Call + 97
15  org.python.python               0x000000010baf4392 PyEval_CallObjectWithKeywords + 159
16  org.python.python               0x000000010ba7c171 PyInstance_New + 123
17  org.python.python               0x000000010ba7355e PyObject_Call + 97
18  org.python.python               0x000000010baef76a PyEval_EvalFrameEx + 20822
19  org.python.python               0x000000010baf49f7 0x10ba66000 + 584183
20  org.python.python               0x000000010baef68d PyEval_EvalFrameEx + 20601
21  org.python.python               0x000000010baea009 PyEval_EvalCodeEx + 533
22  org.python.python               0x000000010bae9dee PyEval_EvalCode + 32
23  org.python.python               0x000000010bb0ce6c 0x10ba66000 + 683628
24  org.python.python               0x000000010bb0cf13 PyRun_FileExFlags + 130
25  org.python.python               0x000000010bb0ca99 PyRun_SimpleFileExFlags + 690
26  org.python.python               0x000000010bb1e3dc Py_Main + 3208
27  libdyld.dylib                   0x00007fff20463f3d start + 1

Thread 1:
0   libsystem_pthread.dylib         0x00007fff20444420 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib         0x00007fff20444420 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib         0x00007fff20444420 start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib         0x00007fff20444420 start_wqthread + 0

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00000001121afe00  rcx: 0x00007ffee41ad468  rdx: 0x0000000000000000
  rdi: 0x0000000000000103  rsi: 0x0000000000000006  rbp: 0x00007ffee41ad490  rsp: 0x00007ffee41ad468
   r8: 0x00007fff80740028   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000246
  r12: 0x0000000000000103  r13: 0x00007febde92ff70  r14: 0x0000000000000006  r15: 0x0000000000000016
  rip: 0x00007fff2041991e  rfl: 0x0000000000000246  cr2: 0x00007febdf87c000
  
Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133

Thread 0 instruction stream not available.

Thread 0 last branch register state not available.


Binary Images:
       0x10ba51000 -        0x10ba54fff  org.python.python (2.7.16 - 2.7.16) <3697BE2C-EB43-3CF9-8B9A-AD7270DA9581> /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
 
.......

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

解决办法

方法1:安装第三方Python 2.7(最稳妥)

系统自带的Python 2.7在Big Sur上的Tk/Tcl组件存在兼容性bug,第三方打包的Python 2.7版本修复了这个问题:

  • 从Python官方渠道下载Python 2.7.18的macOS安装包(选择适配Intel芯片的版本)
  • 双击安装包完成安装,这个版本会自带兼容Big Sur的Tk/Tcl组件
  • 之后运行程序时,用新安装的Python 2.7(默认路径为/usr/local/bin/python2.7)替代系统自带版本

方法2:替换系统Tk/Tcl组件(需谨慎操作)

如果不想重新安装Python,可以手动替换兼容的Tk/Tcl库:

  • 下载适配Big Sur的Tk/Tcl 8.6.x版本安装包并完成安装
  • 找到系统Python依赖的Tk/Tcl路径:/System/Library/Frameworks/Tk.framework和/System/Library/Frameworks/Tcl.framework
  • 右键点击这两个框架,选择「复制」,然后粘贴到桌面做备份
  • 将新安装的Tk/Tcl框架复制到上述系统路径,操作时输入管理员密码即可(你的系统完整性保护已关闭,可直接操作)

方法3:修改程序跳过Tkinter(仅适用于非必需图形界面的程序)

如果程序里的图形界面不是核心功能:

  • 打开程序的Python源码文件,找到导入Tkinter(Python 2)的代码行
  • 如果只是简单弹窗,可替换成命令行输出;如果是复杂图形界面,此方法不适用

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 10:15:34