OpenCV 2.4.12 中的不兼容错误
Incompatible Error in OpenCV 2.4.12
我已经安装了OpenCV,详情如下:
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导入cv库,得到ImportError
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)
终于解决问题了!
导入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,就解决了!
我不确定这是最合适的解决方案,但至少它有效。
我已经安装了OpenCV,详情如下:
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导入cv库,得到ImportError
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)
终于解决问题了!
导入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,就解决了!
我不确定这是最合适的解决方案,但至少它有效。