我已经按照 these instructions, 使用 macports 安装了 numpy 和 opencv但是当我尝试 import cv
或 import cv2
时,我只是得到了段错误,但我不知道为什么。
有什么建议吗?
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Segmentation fault: 11
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault: 11
抱歉,细节太少,但这是一台新计算机,我为此安装了 macports,这是我使用 macports 安装的唯一东西,所以我不知道为什么这不起作用.
编辑:现在我更困惑了。
查看崩溃报告我发现了这一点:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
所以,在黑暗中,我以 super 用户身份运行 python:
$ sudo python
Python 2.7.9 (default, Dec 13 2014, 15:13:49)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>>
作为 super 用户,一切似乎都运行良好。这怎么可能?
最佳答案
如果您仔细查看 python 命令的信息消息,您会发现差异。
来自 buggy :
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault: 11
从工作中:
$ sudo python
Python 2.7.9 (default, Dec 13 2014, 15:13:49)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>>
您的计算机上有两个不同版本的 Python,这可能可以解释您所得到的行为。
关于Python "Segmentation fault: 11"运行时 "import cv"或 "import cv2",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28669587/