pip安装命令:

pip install opencv-python
pip install opencv-contrib-python

若报错可以使用清华源安装cv2:pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

还下不下来那就都这个网站下:https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/opencv-python/

还不不行试试wget,把上面那个网址复制下来 wget + 链接 

老子被下载折腾半天,哭死

 

import cv2的错误记录:

1、cv2 ImportError: libGL.so.1: cannot open shared object file: No such file or directory

缺少相关依赖项,需要更新安装,执行命令:

sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev

 

2、若执行sudo apt-get update报如下错:

Get:1 http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB]
Err:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
  Couldn't create temporary file /tmp/apt.conf.g1YDx9 for passing config to apt-key

打开/tmp目录的权限即可:chmod 777 /tmp

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐