classification
Title: Python Tkinter crashes on macOS 11.1 beta
Type: crash Stage: resolved
Components: macOS Versions: Python 3.9
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: fxcoudert, kode54, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2020-11-27 09:13 by kode54, last changed 2020-12-21 05:10 by ned.deily. This issue is now closed.

Messages (11)
msg381933 - (view) Author: Christopher Snowhill (kode54) Date: 2020-11-27 09:13
The Tkinter module, in a freshly built copy of Python 3.9 built by Brew, using the latest Xcode 12.3 command line tools, crashes on Big Sur 11.1 beta. It emits the following error:

macOS 11 or later required !

I believe I recently read on macOS developer documentation, there is a special behavior in the system version reporting now, possibly only taking effect in 11.1 and newer. Basically, if you query the major version first, you'll get 11 or higher. If you query the minor version first, it will switch on compatibility mode and start reporting either 10.15 or 10.16, I'm not terribly sure which, but it does lie and say it's running version 10.
msg381936 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-11-27 10:02
On macOS 11 the system version is reported as 11.x if the binary was build using Xcode 12, and as 10.16.x for older binaries.
msg381937 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-11-27 10:03
Note that a python installation created using Mac/BuildScript/build-instalelr.py works fine on macOS 11.0 (I haven't tested on 11.1 beta yet). This may be a problem with homebrew or the way it builds Python and/or Tcl/Tk.
msg381989 - (view) Author: Christopher Snowhill (kode54) Date: 2020-11-28 09:38
And I can't report it to Homebrew, either, since they refuse to acknowledge bug reports against beta versions of the OS. I guess I can bug them when 11.1 becomes a stable release, by which time I'll probably be on 11.2.

I'll file Feedback with Apple, too, as they're more likely to actually know what's going on.
msg382028 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-11-29 02:01
I've installed the 11.1 beta (of 2020-11-17) on an Intel-64 virtual machine and installed and run the test suite for the recently released 3.9.1rc1 Universal2 binaries from python.org. The tests, including tkinter tests, run similarly to how they do on 11.0.1. Further, as far as I can tell, there is no place within Python itself where such a message ("macOS 11 or later required !") is emitted; I did not search the Tcl or Tk sources since you didn't say which version is in use. Be aware that 3.9.1rc1 is the first official Python release that supports macOS 11 Big Sur so it may be that the brew version you were using has preliminary patches for Big Sur support that differ from the final versions. Depending what you are trying to do, you might want to use the python.org 3.9.1rc1 or 3.9.1 final (when released) until there is a supported brew version. Or, as Ronald suggest, you may need to track down exactly what and how the brew recipes are building for Tcl, Tk, and Python.  Good luck!
msg382032 - (view) Author: Christopher Snowhill (kode54) Date: 2020-11-29 02:33
Sorry about that. I didn't know that Big Sur support wasn't added until post-3.9.0. I'll check if Brew has a newer version now, and even if not, if I can install a Git version for testing.

Incidentally, the error is occuring inside either the Tk or Tcl frameworks, and it's not a version that Brew supplies. Like the system copies of Python 2 and 3, Brew links its builds against the system Tcl and Tk frameworks, which appear to have some bugs in the beta.

Thanks for testing, though.
msg382033 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-11-29 02:48
If Homebrew links against the Apple-supplied Tcl and Tk frameworks, which are in /System/Library/Frameworks, all bets are off as those are deprecated and hopelessly out-of-date versions of Tcl/Tk 8.5. If tkinter is linked to Tcl and Tk frameworks in /Library/Frameworks and there are Tcl and Tk frameworks there, those are not supplied by Apple; they are either installed by Homebrew from somewhere else (ActiveTcl or perhaps built from source). It can be confusing trying to determine which instance of Tcl or Tk tkinter is actually using at runtime on macOS.  The command:

python3.9 -m test.pythoninfo

will display the patch level of Tk in use.  There is some more detail of how it all works here: https://www.python.org/download/mac/tcltk/
msg382037 - (view) Author: Christopher Snowhill (kode54) Date: 2020-11-29 05:13
That command also crashes with the same error. And I already verified with otool -L on the tkinter shared object file that it does indeed link the /System/Library/Frameworks version of both Tcl and Tk.

In fact, if I remember correctly, Homebrew's entire stance is to import and build as little as possible, always preferring to link to system bundled frameworks, no matter what. Maybe they'll rethink this one.
msg383371 - (view) Author: FX Coudert (fxcoudert) * Date: 2020-12-19 11:39
Hi, Homebrew developer here, we're seeing this with macOS 11.1 and I think it's not a python issue but an Apple's Tcl/Tk issue. The backtrace I have is:

0   libsystem_kernel.dylib        	0x00007fff2031f462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff2034d610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff202a0720 abort + 120
3   Tcl                           	0x00007fff6fe1eb55 Tcl_PanicVA + 398
4   Tcl                           	0x00007fff6fe1ebd5 Tcl_Panic + 128
5   Tk                            	0x00007fff6ff1ead5 TkpInit + 385
6   Tk                            	0x00007fff6fe9e788 0x7fff6fe6d000 + 202632
7   _tkinter.cpython-39-darwin.so 	0x0000000102d2d701 Tcl_AppInit + 84
8   _tkinter.cpython-39-darwin.so 	0x0000000102d289fa _tkinter_create + 975
9   org.python.python             	0x00000001027251bb cfunction_vectorcall_FASTCALL + 203
10  org.python.python             	0x000000010279cff3 call_function + 403
11  org.python.python             	0x000000010279a184 _PyEval_EvalFrameDefault + 27452
12  org.python.python             	0x000000010279db3b _PyEval_EvalCode + 1998
13  org.python.python             	0x00000001026f55d8 _PyFunction_Vectorcall + 248
14  org.python.python             	0x00000001026f4e67 _PyObject_FastCallDictTstate + 212
15  org.python.python             	0x00000001026f5891 _PyObject_Call_Prepend + 139
16  org.python.python             	0x000000010273de96 slot_tp_init + 87
17  org.python.python             	0x00000001027376f7 type_call + 150
18  org.python.python             	0x00000001026f4fa3 _PyObject_MakeTpCall + 266
19  org.python.python             	0x000000010279d027 call_function + 455
20  org.python.python             	0x000000010279a184 _PyEval_EvalFrameDefault + 27452
21  org.python.python             	0x000000010279db3b _PyEval_EvalCode + 1998
22  org.python.python             	0x000000010279356d PyEval_EvalCode + 79
23  org.python.python             	0x00000001027ce5b5 run_eval_code_obj + 110
24  org.python.python             	0x00000001027cd9ad run_mod + 103
25  org.python.python             	0x00000001027cc9dc PyRun_StringFlags + 182
26  org.python.python             	0x00000001027cc8e9 PyRun_SimpleStringFlags + 69
27  org.python.python             	0x00000001027e3802 Py_RunMain + 425
28  org.python.python             	0x00000001027e40c1 pymain_main + 306
29  org.python.python             	0x00000001027e410f Py_BytesMain + 42

This seems confirmed by the fact that I can reproduce with Apple's own python:

$ /usr/bin/python3 
Python 3.8.2 (default, Nov  4 2020, 21:23:28) 
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> root = tkinter.Tk()
macOS 11 or later required !
zsh: abort      /usr/bin/python3

I will file a bug report with Apple.
msg383376 - (view) Author: FX Coudert (fxcoudert) * Date: 2020-12-19 12:11
Reported to Apple as FB8945560
msg383487 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-12-21 05:10
@fxcoudert: If you are trying to link with the Apple-provided system Tcl and Tk frameworks, don't.  They have been seriously broken since macOS 10.7 and stuck at Tk 8.5.9. The only visible Apple action has been to deprecate them. Any Python on macOS that claims to support tkinter (and, hence, IDLE) *must* be able to link with, and preferably supply, newer versions of Tcl and Tk. And for use on current versions of macOS, that also means Tcl/Tk 8.6.x, not 8.5.x.

https://www.python.org/download/mac/tcltk/
History
Date User Action Args
2020-12-21 05:18:33ned.deilylinkissue42691 superseder
2020-12-21 05:10:25ned.deilysetmessages: + msg383487
2020-12-19 12:11:59fxcoudertsetmessages: + msg383376
2020-12-19 11:39:21fxcoudertsetnosy: + fxcoudert
messages: + msg383371
2020-11-29 05:13:49kode54setmessages: + msg382037
2020-11-29 02:48:30ned.deilysetmessages: + msg382033
2020-11-29 02:33:40kode54setmessages: + msg382032
2020-11-29 02:01:24ned.deilysetstatus: open -> closed
resolution: works for me
messages: + msg382028

stage: resolved
2020-11-28 09:38:53kode54setmessages: + msg381989
2020-11-27 10:03:42ronaldoussorensetmessages: + msg381937
2020-11-27 10:02:20ronaldoussorensetmessages: + msg381936
2020-11-27 09:58:28ned.deilysetnosy: + ronaldoussoren, ned.deily
components: + macOS, - Tkinter
2020-11-27 09:13:29kode54create