1、对于Window系统。
1.首先win+R 输入cmd打开控制台
2.输入pip install opencv-python回车进行安装
3.如果找不到pip可以将python安装目录下\Scripts目录加到环境变量,或者换用python-m pip install opencv-python 来进行安装
2、对于Linux系统。
1.直接在shell下运行pip install opencv-python即可
3、安装结束之后,运行python, 输入import cv2来验证是否正确安装。
opencv安装教程python,一起来看看吧:
方法一:进入cmd命令行,直接输入pip install opencv-python 然后回车就可以了
方法二:使用其他下载路径(使用镜像)
指令如下:
1、
pip install opencv-contrib-python
2、清华镜像
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
可换用其他镜像:
阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://pypi.hustunique.com/ 山东理工大学:http://pypi.sdutlinux.org/ 豆瓣:http://pypi.douban.com/simple/
还是报错,再尝试指令:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn opencv-python
遇到权限问题再加user:
pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn opencv-python