依次按照下面的指令进行安装,3.4.1.15需要在Python3.6版本进行安装
conda create --name py3.6 python=3.6 #创建python3.6环境
conda activate py3.6 #进入该环境
pip install opencv-python==3.4.1.15 #安装opencv
#pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python==3.4.1.15
#使用清华镜像进行安装
pip install opencv-contrib-python==3.4.1.15 #安装opencv的其他包
#pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python==3.4.1.15
#使用清华镜像安装
查看OpenCV是否安装成功:
import cv2
print(cv2.__version__)
如果安装失败,可以下载whl文件进行安装
Python各种包的下载地址(自行查找):Archived: Python Extension Packages for Windows - Christoph Gohlke (uci.edu)
清华源下载OpenCV地址:Links for opencv-python (tsinghua.edu.cn)
下载好之后使用pip指令安装即可:
pip install + .whl文件地址
安装过程中,
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python==3.4.1.15
pip install 包的名称 -i https://pypi.tuna.tsinghua.edu.cn/simple
会出现下面的问题:ERROR: Could not install packages due to an OSError: [WinError 5] ,要关闭Jupyter的所有窗口,若关闭后还是安装失败,进行Jupyter的更新
python -m pip install --upgrade pip
更新后在安装opencv-contrib-python