安装OpenCV-Python首先要安装Python环境,也可以直接安装anaconda环境。我这里还是使用单独的Python环境
1、下载Python安装包
https://www.python.org/downloads/
我使用的是windows环境,所以下载对应的安装包,双击安装即可。
C:\Users\xxx>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
2、安装OpenCV-Python
pip install opencv-python
3、测试
在命令行中输入:import cv2,没有报错就说明安装成功了.
C:\Users\xxx>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
至此,OpenCV-Python就安装完成.