1

在 python 中的 Mac OS 10.11 上,我在执行以下操作时遇到中止陷阱:

from moviepy.editor import *
from Tkinter import *
root = Tk()

中止陷阱如下所示:

2016-01-27 16:01:24.723 Python[13070:104308] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7ffa632d9bd0
2016-01-27 16:01:24.724 Python[13070:104308] An uncaught exception was raised
2016-01-27 16:01:24.724 Python[13070:104308] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7ffa632d9bd0
2016-01-27 16:01:24.724 Python[13070:104308] (
    0   CoreFoundation                      0x00007fff933e4ae2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff92bdb73c objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff933e7b9d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff93320601 ___forwarding___ + 1009
    4   CoreFoundation                      0x00007fff93320188 _CF_forwarding_prep_0 + 120
    5   Tk                                  0x0000000110f42958 TkpInit + 476
    6   Tk                                  0x0000000110ebda7e Tk_Init + 1799
    7   _tkinter.so                         0x000000010cdb8b9d Tcl_AppInit + 82
    8   _tkinter.so                         0x000000010cdb8547 Tkinter_Create + 1120
    9   Python                              0x0000000108de7bcd PyEval_EvalFrameEx + 26858
    10  Python                              0x0000000108de10f1 PyEval_EvalCodeEx + 1583
    11  Python                              0x0000000108d85fb1 function_call + 352
    12  Python                              0x0000000108d67eb0 PyObject_Call + 99
    13  Python                              0x0000000108d72cb8 instancemethod_call + 173
    14  Python                              0x0000000108d67eb0 PyObject_Call + 99
    15  Python                              0x0000000108deb06f PyEval_CallObjectWithKeywords + 165
    16  Python                              0x0000000108d70f5c PyInstance_New + 126
    17  Python                              0x0000000108d67eb0 PyObject_Call + 99
    18  Python                              0x0000000108de7a27 PyEval_EvalFrameEx + 26436
    19  Python                              0x0000000108de10f1 PyEval_EvalCodeEx + 1583
    20  Python                              0x0000000108de0abc PyEval_EvalCode + 54
    21  Python                              0x0000000108e04ea1 run_mod + 53
    22  Python                              0x0000000108e04ccc PyRun_InteractiveOneFlags + 377
    23  Python                              0x0000000108e047c5 PyRun_InteractiveLoopFlags + 192
    24  Python                              0x0000000108e0466f PyRun_AnyFileExFlags + 60
    25  Python                              0x0000000108e16445 Py_Main + 3137
    26  libdyld.dylib                       0x00007fff916435ad start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
2016-01-27 16:01:24.725 Python[13070:104308] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7ffa632d9bd0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff933e4ae2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff92bdb73c objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff933e7b9d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff93320601 ___forwarding___ + 1009
    4   CoreFoundation                      0x00007fff93320188 _CF_forwarding_prep_0 + 120
    5   Tk                                  0x0000000110f42958 TkpInit + 476
    6   Tk                                  0x0000000110ebda7e Tk_Init + 1799
    7   _tkinter.so                         0x000000010cdb8b9d Tcl_AppInit + 82
    8   _tkinter.so                         0x000000010cdb8547 Tkinter_Create + 1120
    9   Python                              0x0000000108de7bcd PyEval_EvalFrameEx + 26858
    10  Python                              0x0000000108de10f1 PyEval_EvalCodeEx + 1583
    11  Python                              0x0000000108d85fb1 function_call + 352
    12  Python                              0x0000000108d67eb0 PyObject_Call + 99
    13  Python                              0x0000000108d72cb8 instancemethod_call + 173
    14  Python                              0x0000000108d67eb0 PyObject_Call + 99
    15  Python                              0x0000000108deb06f PyEval_CallObjectWithKeywords + 165
    16  Python                              0x0000000108d70f5c PyInstance_New + 126
    17  Python                              0x0000000108d67eb0 PyObject_Call + 99
    18  Python                              0x0000000108de7a27 PyEval_EvalFrameEx + 26436
    19  Python                              0x0000000108de10f1 PyEval_EvalCodeEx + 1583
    20  Python                              0x0000000108de0abc PyEval_EvalCode + 54
    21  Python                              0x0000000108e04ea1 run_mod + 53
    22  Python                              0x0000000108e04ccc PyRun_InteractiveOneFlags + 377
    23  Python                              0x0000000108e047c5 PyRun_InteractiveLoopFlags + 192
    24  Python                              0x0000000108e0466f PyRun_AnyFileExFlags + 60
    25  Python                              0x0000000108e16445 Py_Main + 3137
    26  libdyld.dylib                       0x00007fff916435ad start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

moviepy 是最新版本(0.2.2.11),Tkinter 是 Tcl/Tk 网站推荐的构建版本。我还注意到,当我导入moviepy.editor 时,Dock 中会弹出一个Tkinter 符号,好像Tk() 对象正在被moviepy 实例化?很奇怪,很沮丧。

4

1 回答 1

0

固定的。原来这是 matplotlib 的一个奇怪问题。正在做:

import matplotlib
matplotlib.use('TkAgg')

成功了。在这个网站上还有一些其他问题,这个中止陷阱出现在哪里,也许这就是所有需要做的事情。

于 2016-01-27T23:06:55.133 回答