python安装opencv
anaconda 下创建一个python3.6的虚拟环境,进入虚拟环境开始安装:
先安装 opencv-python
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
安装过程
looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
collecting opencv-python
downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/c3/798bd7b8f78430f82ec0660b753106717e4e4bb8032ce56f77d8577cb24b/opencv_python-4.5.5.64-cp36-abi3-win_amd64.whl (35.4 mb)
|████████████████████████████████| 35.4 mb 218 kb/s
collecting numpy>=1.13.3
using cached https://pypi.tuna.tsinghua.edu.cn/packages/ea/bc/da526221bc111857c7ef39c3af670bbcf5e69c247b0d22e51986f6d0c5c2/numpy-1.19.5-cp36-cp36m-win_amd64.whl (13.2 mb)
installing collected packages: numpy, opencv-python
successfully installed numpy-1.19.5 opencv-python-4.5.5.64安装opencv-contrib-python
pip install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple
安装过程
looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
collecting opencv-contrib-python
downloading https://pypi.tuna.tsinghua.edu.cn/packages/2e/63/c02ffce9f182dd77fad7ee1f333a6a2aca1a5a2c14a683d30b5d2bd8d8db/opencv_contrib_python-4.5.5.64-cp36-abi3-win_amd64.whl (42.2 mb)
|████████████████████████████████| 42.2 mb 311 kb/s
requirement already satisfied: numpy>=1.13.3 in c:\users\yang\.conda\envs\kivy\lib\site-packages (from opencv-contrib-python) (1.19.5)
installing collected packages: opencv-contrib-python
successfully installed opencv-contrib-python-4.5.5.64此种方法安装后,import cv2 as cv后,代码可以正常运行
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论