小白一只,安装过程如下
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
import cv,就出现这个
import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/cv.py", line 1, in <module>
from cv2.cv import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: libopencv_contrib.2.4.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/cv2.so
Reason: unsafe use of relative rpath libopencv_contrib.2.4.dylib in /usr/local/lib/python2.7/site-packages/cv2.so with restricted binary
你的系统是不是Mac 10.11
系统的安全机制不允许使用不安全的相对连接
解决方法
1.关掉这个机制
重启 Mac,按住 Command+R 键直到 Apple logo 出现,进入 Recovery Mode
点击 Utilities > Terminal
d在 Terminal 中输入 csrutil disable,之后回车
重启 Mac
2.把相对路径替换成绝对路径
GitHub - zsirui/opencv-fix-path-on-OSX: Fix path error when installed OpenCV 3.1.0 through CMake build on OSX/修复在OSX下通过CMake编译安装OpenCV3.1.0在python中导入cv库所报相对路径错误