无法在OSX El Capitan(opencv3.1.0)上的python2.7中导入cv2

时间:2016-01-07 03:45:39

标签: python python-2.7 opencv importerror osx-elcapitan

我已经使用这个tutorial在我的mac上安装opencv(没有虚拟环境)。但是,当我运行python并想要导入cv2时,我收到以下错误:

>>> import cv2
Traceback (most recent call last):
File “”, line 1, in
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: lib/libopencv_reg.3.1.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/cv2.so
Reason: image not found

我已经尝试了here中所述的解决方案,但它没有奏效。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:0)

对我来说,这是通过指定opencv库的路径来解决的:

export DYLD_LIBRARY_PATH=/full/path/to/opencv/build/lib:$DYLD_LIBRARY_PATH