opencv:python导入时的段错误在mac上导入cv2

时间:2014-09-28 03:41:25

标签: python opencv

我跑:

brew install opencv

python -v
>>> import cv2
dlopen("/usr/local/Cellar/opencv/2.4.8.2/lib/python2.7/site-packages/cv2.so", 2);
Segmentation fault: 11

当我在lldb下运行导入时,出现此错误:

* thread #1: tid = 0xa9eb76, 0x0000000000000000, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
error: memory read failed for 0x0

回溯是:

  * frame #0: 0x0000000000000000
    frame #1: 0x00000001029f4b8e Python`PyEval_GetGlobals + 23
    frame #2: 0x0000000102a036e4 Python`PyImport_Import + 131
    frame #3: 0x0000000102a01ec6 Python`PyImport_ImportModule + 31
    frame #4: 0x0000000102806497 cv2.so`initcv2 + 26
    frame #5: 0x000000010009b932 Python`_PyImport_LoadDynamicModule + 150
    frame #6: 0x000000010009b649 Python`___lldb_unnamed_function1582$$Python + 274
    frame #7: 0x000000010009b225 Python`___lldb_unnamed_function1580$$Python + 276
    frame #8: 0x0000000100099522 Python`PyImport_ImportModuleLevel + 1153
    frame #9: 0x000000010007f776 Python`___lldb_unnamed_function1423$$Python + 132
    frame #10: 0x000000010000df72 Python`PyObject_Call + 101
    frame #11: 0x000000010008a01f Python`PyEval_CallObjectWithKeywords + 93
    frame #12: 0x0000000100087110 Python`PyEval_EvalFrameEx + 12115
    frame #13: 0x0000000100084093 Python`PyEval_EvalCodeEx + 1641
    frame #14: 0x0000000100083a24 Python`PyEval_EvalCode + 54
    frame #15: 0x00000001000a2c2c Python`___lldb_unnamed_function1610$$Python + 53
    frame #16: 0x00000001000a2cd3 Python`PyRun_FileExFlags + 137
    frame #17: 0x00000001000a2821 Python`PyRun_SimpleFileExFlags + 718
    frame #18: 0x00000001000b3363 Python`Py_Main + 2995

1 个答案:

答案 0 :(得分:4)

重新安装python修复它。嗬!