Hey I’m having this same problem on my M1 Mac running native Python 3.10.12 through conda
, whenever I use fork or fork_unsynchronized
I get the following error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
(
0 CoreFoundation 0x000000018d2b48c0 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x000000018cdadeb4 objc_exception_throw + 60
2 CoreFoundation 0x000000018d2d9bac _CFBundleGetValueForInfoKey + 0
3 AppKit 0x0000000190a29874 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 188
4 AppKit 0x0000000190a297ac -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
5 libtk8.6.dylib 0x00000001060e8230 TkMacOSXMakeRealWindowExist + 536
6 libtk8.6.dylib 0x00000001060e7e94 TkWmMapWindow + 76
7 libtk8.6.dylib 0x0000000106045238 MapFrame + 76
8 libtcl8.6.dylib 0x0000000105f66dec TclServiceIdle + 88
9 libtcl8.6.dylib 0x0000000105f471e0 Tcl_DoOneEvent + 120
10 libtk8.6.dylib 0x00000001060d8e80 TkpInit + 792
11 libtk8.6.dylib 0x000000010603dcd0 Initialize + 2424
12 _tkinter.cpython-310-darwin.so 0x0000000102eee0a4 Tkapp_New + 876
13 _tkinter.cpython-310-darwin.so 0x0000000102eedb18 _tkinter_create + 648
14 python3.10 0x000000010109f880 cfunction_vectorcall_FASTCALL + 200
15 python3.10 0x000000010113d540 call_function + 524
16 python3.10 0x0000000101138e60 _PyEval_EvalFrameDefault + 24940
17 python3.10 0x0000000101132364 _PyEval_Vector + 2036
18 python3.10 0x0000000101139658 _PyEval_EvalFrameDefault + 26980
19 python3.10 0x0000000101132364 _PyEval_Vector + 2036
20 python3.10 0x000000010104ec64 method_vectorcall + 172
21 python3.10 0x000000010113d540 call_function + 524
22 python3.10 0x0000000101138e60 _PyEval_EvalFrameDefault + 24940
23 python3.10 0x0000000101132364 _PyEval_Vector + 2036
24 python3.10 0x000000010104b850 _PyObject_FastCallDictTstate + 320
25 python3.10 0x000000010104c454 _PyObject_Call_Prepend + 176
26 python3.10 0x00000001010c3394 slot_tp_init + 116
27 python3.10 0x00000001010bbd64 type_call + 456
28 python3.10 0x000000010104b59c _PyObject_MakeTpCall + 612
29 python3.10 0x000000010113d5d8 call_function + 676
30 python3.10 0x00000001011393bc _PyEval_EvalFrameDefault + 26312
31 python3.10 0x0000000101132364 _PyEval_Vector + 2036
32 python3.10 0x0000000101139658 _PyEval_EvalFrameDefault + 26980
33 python3.10 0x0000000101132364 _PyEval_Vector + 2036
34 python3.10 0x0000000101139658 _PyEval_EvalFrameDefault + 26980
35 python3.10 0x0000000101132364 _PyEval_Vector + 2036
36 python3.10 0x0000000101139658 _PyEval_EvalFrameDefault + 26980
37 python3.10 0x0000000101132364 _PyEval_Vector + 2036
38 python3.10 0x000000010113d540 call_function + 524
39 python3.10 0x0000000101138e38 _PyEval_EvalFrameDefault + 24900
40 python3.10 0x0000000101132364 _PyEval_Vector + 2036
41 python3.10 0x000000010113d540 call_function + 524
42 python3.10 0x0000000101138e38 _PyEval_EvalFrameDefault + 24900
43 python3.10 0x0000000101132364 _PyEval_Vector + 2036
44 python3.10 0x000000010104ed10 method_vectorcall + 344
45 python3.10 0x0000000101204830 thread_run + 180
46 python3.10 0x00000001011a0230 pythread_wrapper + 48
47 libsystem_pthread.dylib 0x000000018d163034 _pthread_start + 136
48 libsystem_pthread.dylib 0x000000018d15de3c thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException
zsh: abort /Users/username/miniforge3/bin/python
/Users/username/miniforge3/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 2 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
I’m basically trying to run customtkinter
through fork_unsynchronized
, which works find on Intel Windows machines but it won’t work at all on my M1 Mac. It seems to be a problem with how the M1 handles threading and I’ve spent hours trying to find a fix but I’m not very advanced with Python and get lost in multiprocessing
. It almost works when I run my scamp
code in its own thread before starting the customtkinter
GUI but my code runs on a while
loop and when I start the scamp
thread, it starts the while
loop over and over until I run out of threads.