中止陷阱:运行python脚本时为6

时间:2014-06-18 13:43:54

标签: python macos pyglet psychopy

我正在研究一个显示动画的python程序,因此我正在使用pyglet。到目前为止,我一直在使用Psychopy附带的python编译器,但现在我需要让这个程序尽可能独立。

我已经使用Windows机器完成了这项任务,对于OSX,我已经关注this post以安装pyglet。但是,当我现在运行程序时,它返回:

>>>> python 140603_plaid8.py
2014-06-17 12:25:02.512 Python[1713:d07] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/fk/1plt8wj53_d183pv59scmg4m0000gn/T/org.python.python.savedState
no input received
CONFIG FILE LOADED
TRIALS FILE LOADED
2014-06-17 12:25:02.661 Python[1713:d07] -[NSApplication _setup:]: unrecognized selector sent to instance 0x102d3b5c0
2014-06-17 12:25:02.662 Python[1713:d07] An uncaught exception was raised
2014-06-17 12:25:02.663 Python[1713:d07] -[NSApplication _setup:]: unrecognized selector sent to instance 0x102d3b5c0
2014-06-17 12:25:02.663 Python[1713:d07] (
    0   CoreFoundation                      0x00007fff8948f25c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff87f16e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8949212d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff893ed322 ___forwarding___ + 1010
    4   CoreFoundation                      0x00007fff893ecea8 _CF_forwarding_prep_0 + 120
    5   Tk                                  0x0000000108253ed6 TkpInit + 459
    6   Tk                                  0x00000001081d1b0f Tk_Init + 1687
    7   _tkinter.so                         0x00000001080b4c0d Tcl_AppInit + 77
    8   _tkinter.so                         0x00000001080b3657 Tkinter_Create + 919
    9   Python                              0x00000001000c2fad PyEval_EvalFrameEx + 21405
    10  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    11  Python                              0x000000010003eac0 function_call + 176
    12  Python                              0x000000010000ceb2 PyObject_Call + 98
    13  Python                              0x000000010001f56d instancemethod_call + 365
    14  Python                              0x000000010000ceb2 PyObject_Call + 98
    15  Python                              0x00000001000bc957 PyEval_CallObjectWithKeywords + 87
    16  Python                              0x000000010002285e PyInstance_New + 126
    17  Python                              0x000000010000ceb2 PyObject_Call + 98
    18  Python                              0x00000001000c0c60 PyEval_EvalFrameEx + 12368
    19  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    20  Python                              0x000000010003eac0 function_call + 176
    21  Python                              0x000000010000ceb2 PyObject_Call + 98
    22  Python                              0x000000010001f56d instancemethod_call + 365
    23  Python                              0x000000010000ceb2 PyObject_Call + 98
    24  Python                              0x00000001000bc957 PyEval_CallObjectWithKeywords + 87
    25  Python                              0x000000010002285e PyInstance_New + 126
    26  Python                              0x000000010000ceb2 PyObject_Call + 98
    27  Python                              0x00000001000c0c60 PyEval_EvalFrameEx + 12368
    28  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    29  Python                              0x00000001000c50d6 PyEval_EvalCode + 54
    30  Python                              0x00000001000e995e PyRun_FileExFlags + 174
    31  Python                              0x00000001000e9bfa PyRun_SimpleFileExFlags + 458
    32  Python                              0x0000000100100c0d Py_Main + 3101
    33  Python                              0x0000000100000f14 Python + 3860
    34  ???                                 0x0000000000000002 0x0 + 2
)
2014-06-17 12:25:02.664 Python[1713:d07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x102d3b5c0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8948f25c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff87f16e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8949212d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff893ed322 ___forwarding___ + 1010
    4   CoreFoundation                      0x00007fff893ecea8 _CF_forwarding_prep_0 + 120
    5   Tk                                  0x0000000108253ed6 TkpInit + 459
    6   Tk                                  0x00000001081d1b0f Tk_Init + 1687
    7   _tkinter.so                         0x00000001080b4c0d Tcl_AppInit + 77
    8   _tkinter.so                         0x00000001080b3657 Tkinter_Create + 919
    9   Python                              0x00000001000c2fad PyEval_EvalFrameEx + 21405
    10  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    11  Python                              0x000000010003eac0 function_call + 176
    12  Python                              0x000000010000ceb2 PyObject_Call + 98
    13  Python                              0x000000010001f56d instancemethod_call + 365
    14  Python                              0x000000010000ceb2 PyObject_Call + 98
    15  Python                              0x00000001000bc957 PyEval_CallObjectWithKeywords + 87
    16  Python                              0x000000010002285e PyInstance_New + 126
    17  Python                              0x000000010000ceb2 PyObject_Call + 98
    18  Python                              0x00000001000c0c60 PyEval_EvalFrameEx + 12368
    19  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    20  Python                              0x000000010003eac0 function_call + 176
    21  Python                              0x000000010000ceb2 PyObject_Call + 98
    22  Python                              0x000000010001f56d instancemethod_call + 365
    23  Python                              0x000000010000ceb2 PyObject_Call + 98
    24  Python                              0x00000001000bc957 PyEval_CallObjectWithKeywords + 87
    25  Python                              0x000000010002285e PyInstance_New + 126
    26  Python                              0x000000010000ceb2 PyObject_Call + 98
    27  Python                              0x00000001000c0c60 PyEval_EvalFrameEx + 12368
    28  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    29  Python                              0x00000001000c50d6 PyEval_EvalCode + 54
    30  Python                              0x00000001000e995e PyRun_FileExFlags + 174
    31  Python                              0x00000001000e9bfa PyRun_SimpleFileExFlags + 458
    32  Python                              0x0000000100100c0d Py_Main + 3101
    33  Python                              0x0000000100000f14 Python + 3860
    34  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

我不明白这个错误意味着什么,任何人都可以帮助我理解我做错了什么?

5 个答案:

答案 0 :(得分:10)

使用OpenCV时遇到类似的错误。搜寻了一段时间后,我发现该错误可能与新的macOS有关。它不允许调用未版本控制的dylib。我在这里找到了解决方案:

https://forums.developer.apple.com/thread/119429

在您的终端中:

brew update && brew upgrade && brew install openssl
cd /usr/local/Cellar/openssl/1.0.2t/lib
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/
cd /usr/local/lib
sudo ln -s libssl.1.0.0.dylib libssl.dylib
sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib
pip3 install --upgrade packagename

答案 1 :(得分:10)

像这样运行您的Python脚本:

$ PYTHONVERBOSE=3 python your_script.py

检查Abort trap: 6之前的最后一条语句,例如:

import asn1crypto._perf._big_num_ctypes # precompiled from ...
Abort trap: 6

然后,在独立的Python解释器中运行它:

$ python
Python 2.7.17 (default, May  6 2020, 10:47:56) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.32.59)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asn1crypto._perf._big_num_ctypes
Abort trap: 6

这时,您知道问题源自asn1crypto模块。深入该文件并查找更多...

但是对于这种特殊情况,只需删除asn1crypto软件包的目录,然后重试。 (pip uninstall asn1crypto可能不起作用。)

答案 2 :(得分:1)

在这种情况下,错误消息并没有告诉我们。你需要做什么(在一般的调试中)是找出成功和失败的原因,以便缩小问题范围。

从一个只导入pyglet的脚本开始。如果可以,那么导入pyglet并打开一个窗口等......

当你知道哪一行导致错误发生时报告。

乔恩

答案 3 :(得分:1)

我找到了出现此错误的原因。这是因为我使用库TKinter,如果我注释掉我使用TKinter的行,则不会出现此错误并继续执行该程序。

当我发现在OSX中使用TKinter的正确方法时,我会编辑这个答案。但我首先关注的是pyglet动画,它在OSX中不起作用,但它在Windows中起作用。

答案 4 :(得分:0)

在Python中(在MacOS 10.15.5上)导入asn1crypto时遇到相同的失败。卸载然后使用brew重新安装openssl对我有用:

brew uninstall --ignore-dependencies openssl

brew告诫我,还有一些剩余的文件没有删除(例如/usr/local/etc/openssl@1.1/cert.pem),这些文件已移至备份位置:

sudo mv /usr/local/etc/openssl@1.1 ~/openssl@1.1-usrlocalbackup

然后使用brew重新安装openssl解决了该问题:

brew install openssl