先下载cv2安装包,下载链接
https://www.lfd.uci.edu/~gohlke/pythonlibs/我的python3.6下的
opencv_python‑3.4.2‑cp36‑cp36m‑win_amd64.whl
3.4.2是cv2的版本,cp36是python版本,python3.6的
下完之后安装
cmd终端输入
pip install C:\程序安装包\opencv_python-3.4.2-cp36-cp36m-win_amd64.whl
就是
pip install opencv安装包地址\文件名
如下
C:\Users\mqq>pip install C:\程序安装包\opencv_python-3.4.2-cp36-cp36m-win_amd64.whl
Processing c:\程序安装包\opencv_python-3.4.2-cp36-cp36m-win_amd64.whl
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.2
安装完查看,没报错就成功了
C:\Users\mqq>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.2'
>>>