此错误原因一般是库没有安装好,尝试安装库文件
- 错误尝试:pip install cv2
既然是cv2的库不存在,一个朴素想法就是安装cv2,使用pip install cv2
,发现没有这个库。
ERROR: Could not find a version that satisfies the requirement cv2
ERROR: No matching distribution found for cv2
- 正确做法:pip install opencv-python
python的cv2的库名称叫opencv-python,所以应该用pip install opencv-python
导入库。
如果下载速度较慢,可以采用清华镜像源,
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python
,以及conda安装conda install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python