python无法导入opencv,因为它无法找到libjpeg.8.dylib

试图在Mac OSX上运行opencv for python – Mavericks但是从python导入cv时仍然没有找到libjpeg.8.dylib找不到的图像

(最近从Mountain Lion更新)

这就是我做的:

1.brew tap homebrew / science

2.brew install opencv

3.python

4.import cv

– 发现以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py", line 1, in <module>
    from cv2.cv import *
ImportError: dlopen(/usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /usr/local/Cellar/opencv/2.4.9/lib/libopencv_highgui.2.4.dylib
  Reason: image not found

>我找了libjpeg.8.dylib并在/usr/local/Cellar / jpeg / 8d / lib /中发现它,显然,它不是libopencv_highgui.2.4.dylib所在的位置.

我对Mac OS和自制软件有点新意.任何人都可以解释如何解决此错误并使opencv运行?我有预装了Mac的python和自制软件安装的python.

谢谢.

解决方法:

快速而肮脏的解决方案是在/usr/local/lib文件夹中创建一个指向libjpeg.8.dylib实际位置的符号链接,如下所示:


$sudo ln -s /usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib /usr/local/lib/libjpeg.8.dylib

问题是opencv和python期望libjpeg.8.dylib在/usr/local/lib /中,但是homebrew将它安装在/usr/local/Cellar /中,因此会出现恼人的错误.

上一篇:抖音榜单Api:明星榜


下一篇:如何将GRAL图输出到JPG?