安装命令
conda install -y -c conda-forge opencv
测试
➜ ~ python -c "import cv2"
出现异常
- freetype版本不匹配
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: dlopen(/Users/yanchao.jia/anaconda3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libfreetype.6.dylib
Referenced from: /Users/yanchao.jia/anaconda3/lib/libopencv_freetype.3.4.dylib
Reason: Incompatible library version: libopencv_freetype.3.4.dylib requires version 22.0.0 or later, but libfreetype.6.dylib provides version 21.0.0
- 解决方法
conda uninstall freetype
conda install -y -c conda-forge opencv
解决思路是:
使用的是conda安装opencv,提示有库版本不匹配,如libfreetype.6.dylib
- 先找到所有 libfreetype.6.dylib文件
sudo find / -name libfreetype.6.dylib
- 优先检测anaconda环境下的libfreetype.6.dylib版本号
➜ ~ otool -L /Users/yanchao.jia/anaconda3/lib/libopencv_freetype.3.4.dylib
- 确实是21.0.0
- 先卸载再安装测试(可以先试试update,我这直接update未成功)
conda uninstall freetype
conda install -y -c conda-forge opencv
python -c "import cv2"
网友评论