search

Home  >  Q&A  >  body text

opencv2 - mac下安装opencv python中导入错误

小白一只,安装过程如下
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

PHPzPHPz2785 days ago771

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 18:03:23

    Is your system Mac 10.11?
    The system’s security mechanism does not allow the use of insecure relative connections
    Solution

    1. Turn off this mechanism

    1. Restart your Mac, hold down the Command+R keys until the Apple logo appears, enter Recovery Mode

    2. Click Utilities > Terminal

    3. dEnter csrutil disable in Terminal and press Enter

    4. Restart Mac

    2. Replace relative paths with absolute paths

    GitHub - zsirui/opencv-fix-path-on-OSX: Fix path error when installed OpenCV 3.1.0 through CMake build on OSX Path error

    reply
    0
  • Cancelreply