Python "Segmentation fault: 11"运行时 "import cv"或 "import cv2"

标签 python macos python-2.7 opencv macports

我已经按照 these instructions, 使用 macports 安装了 numpy 和 opencv但是当我尝试 import cvimport 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/

相关文章:

python - 无法使用 resample.ohlc() 方法 - DataError : No numeric types to aggregate

python - python中的自定义日期格式解析

swift - NSTableView/NSOutlineView 重新加载指定行

objective-c - 有没有办法在浏览器上将 Cocoa 应用程序作为工作表打开?

python - 在 Kivy for Python 中按下按钮时更新标签的文本

python - 在 OpenShift Python Hosting 上的端口上打开套接字

python - (Python 类型提示)如何指定当前定义为方法返回类型的类型?

python - sqlalchemy编译器问题

objective-c - 我的核心数据数据模型中的实体之一没有被删除

python-2.7 - Thrift Build 因 "src/thrift/transport/TSSLSocket.cpp:43:10: fatal error: ' openssl/opensslv.h' 找不到文件而停止”