写在之前:本篇为Python3.7安装cv2踩过的坑
一、cv2模块的下载安装
坑:
使用pip install cv2
安装CV2模块报错:
Collecting cv2
Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2
You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
提示版本不匹配。
解决:
安装cv2模块不能直接用命令pip install cv2
安装,要用pip install opencv-python
安装。
说明: 当然可能默认下载的模块跟你的Python环境不匹配,到下面的镜像中找和你版本匹配的进行下载:
https://pypi.tuna.tsinghua.edu.cn/simple/opencv-python/
我下载的是opencv_python-3.4.3.18-cp37-cp37m-win_amd64.whl
,37是指你的Py下载下来了。
二、检查cv2是否安装成功
输入命令:import cv2
,成功返回即表示安装成功,如下图: