Python“分段错误:11";当运行“导入简历"时或“导入cv2"

问题描述:

我已经按照

I have installed numpy and opencv using macports as per these instructions, but when I try import cv or import cv2 I just get the segfault and I have no idea why.

有什么建议吗?

$ 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上安装的唯一内容,所以我不知道为什么这无法正常工作

Sorry there are so few details, but this is a new computer and I installed macports on it just for this, and these are the only things I've installed with macports, so I have no idea why this isn't working.

浏览崩溃报告,我发现:

Looking through the crash report I found this:

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000

因此,在黑暗中拍摄时,我以超级用户身份运行python:

So, as a shot in the dark, I ran python as super user:

$ 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
>>>

作为超级用户,一切似乎运行良好.这怎么可能?

As super user, everything appears to run fine. How is this possible?

如果您仔细查看python命令的信息消息,就会发现其中的区别.

If you look closely to the info message of your python command, you will see the difference.

从一辆越野车上来:

$ 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版本,它们可能会解释您的行为.

You have two different versions of Python on your machine which might explain the behaviors you got.