2015-12-13 126 views
1

我已經安裝了OpenCV的和細節如下:不兼容的錯誤2.4.12

brew info opencv homebrew/science/opencv: stable 2.4.12 (bottled),

HEAD Open source computer vision library http://opencv.org/ /usr/local/Cellar/opencv/2.4.12 (225 files, 36M)

然後,我跑了Python導入簡歷庫,並獲得導入錯誤

ImportError: dlopen(./cv2.so, 2): Library not loaded: /usr/local/lib/libpng16.16.dylib Referenced from: /usr/local/Cellar/opencv/2.4.12/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 35.0.0 or later, but libpng16.16.dylib provides version 34.0.0

我發現了一些相關的問題,並按照建議重新安裝libpng以獲取最新版本。不幸的是,它仍然不工作..

這裏是libnpg的細節:

brew info libpng libpng: stable 1.6.19 (bottled), HEAD Library for manipulating PNG images http://www.libpng.org/pub/png/libpng.html

/usr/local/Cellar/libpng/1.6.19 (17 files, 1.2M)

回答

1

我終於解決這個問題!

導入cv,cv2模塊時會加載目錄:/usr/local/lib/libpng16.16.dylib中的「libpng16.16.dylib」。

即使我將libpng的版本更新爲最新版本,新版本的「libpng16.16.dylib」仍保存在:/usr/local/Cellar/libpng/1.6.19而不是/ usr/local /lib/libpng16.16.dylib。

因此,我將最新版本的「libpng16.16.dylib」複製到目錄:/usr/local/lib/libpng16.16.dylib,並且解決了!

我不確定這是最合適的解決方案,但至少可以工作。