2019-01-01 | Python | Unlock

python3安装opencv爬坑步骤

  各种尝试安装opencv,但是导入都是失败,这是什么问题呢?

  以前总是这样安装:pip3 install opencv-python,安装是成功了,可是导入的时候总是报错,没找到cv2的包,这里,再安装一个opencv-contrib-python模块。

  试试 pip3 install opencv-contrib-python

  这时候,如果导入cv2还报错,请按照如下错误解决问题:

  (1)ImportError: libjasper.so.1: cannot open shared object file: No such file or directory

  请安装 apt install libjasper-dev

  (2)ImportError: libQtGui.so.4: cannot open shared object file: No such file or directory

  请安装 apt install libqtgui4

  (3)ImportError: libQtTest.so.4: cannot open shared object file: No such file or directory

  请安装 apt install libqt4-test


  这些问题,看着不难,但是从遇到到解决,还是花了不少时间。总结下,还是直接一次安装完比较好,这里提供一份完整爬坑指南:

  pip3 install opencv-contrib-python

  apt install libjasper-dev libqtgui4 libqt4-test libhdf5-dev libatlas-base-dev

  apt update


  相信到了这里,应该能搞定了!

评论加载中