1.在windows和Ubuntu上,用pip安装opencv2会经常失败,原因是资源包不匹配。
2.windows上最好是下载相应的包,然后pip安装。
3.ubuntu 上比较好的方法是通过conda命令安装
conda install -c conda-forge opencv
安装后,import cv2 如果报错:
ImportError: (路径)libopencv_dnn.so.3.4: undefined symbol: _ZNK6google8protobuf7Message25InitializationErrorStringB5cxx11Ev
是因为:The opencv package is defaults is not compatible with the the libprotobuf and protobuf packages from conda-forge. Installing these package from defaults using conda install -c defaults libprotobuf protobuf should fix the import failure.(来源:https://github.com/ContinuumIO/anaconda-issues/issues/9601)
4.出现上述错误,则使用命令 conda install -c conda-forge opencv