因为找不到libjpeg

因为找不到libjpeg

本文介绍了python无法导入opencv,因为找不到libjpeg.8.dylib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图在Mac OSX上使用适用于python的opencv-Mavericks,但在从python导入cv时仍未找到libjpeg.8.dylib的映像

Trying to get opencv for python working on Mac OSX - Mavericks but keep getting an image not found for libjpeg.8.dylib when doing import cv from python

(最近从Mountain Lion更新)

(Recently updated from 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


  1. 我寻找了libjpeg.8.dylib并在/usr/local/Cellar/jpeg/8d/lib/中找到了它,显然,它不在libopencv_highgui.2.4.dylib所寻找的位置.
  1. I looked for libjpeg.8.dylib and found it in /usr/local/Cellar/jpeg/8d/lib/ which, apparently, is not where libopencv_highgui.2.4.dylib is looking.

我对Mac OS和Homebrew有点陌生.谁能解释如何解决此错误并使opencv运行?我已经预装了Mac随附的python,而它们是由自制软件安装的.

I'm a bit new to Mac OS and homebrew. Could anyone explain how to resolve this error and get opencv running? I have the python that comes preinstalled with Mac and them python installed by homebrew.

谢谢.

推荐答案

一种快速而又肮脏的解决方案是在/usr/local/lib文件夹中建立一个指向libjpeg.8.dylib实际位置的符号链接. ,就像这样:

The quick and dirty solution for this is to make a symlink inside of the /usr/local/lib folder pointing to the actual location of libjpeg.8.dylib, like this:


$ 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/中,但是自制软件将其安装在/usr/local/Cellar/中,因此令人讨厌的错误.

The problem is opencv and python expect libjpeg.8.dylib to be in /usr/local/lib/ but homebrew installs it in /usr/local/Cellar/, hence annoying error.

这篇关于python无法导入opencv,因为找不到libjpeg.8.dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:30