赞
踩
最近写一批程序,需要用到opencv里面的函数,但是导入cv2的时候,新电脑提示没有安装,所以首先安装opencv的库,直接pip install opencv-python,不过报错了。
然后从镜像站中安装opencv,直接pip install -i https://mirrors.aliyun.com/pypi/simple opencv-python,不过仍然报错,报错原因和上一次一样:Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
网上找了很多办法,有的说不要用PEP517,有的说不要用默认的路径,有的说从镜像站下载,我都试过了,没有解决问题。
后来从stackoverflow上找到类似的问题:c++ - ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly (cl was not found in PATH) - Stack Overflow
回答的建议是:
I have successfully resolved this error issue. There are two methods of going about it, you can use either:
- Downgrading Python 3.9 to Python 3.8
- Use conda instead of pip (if you have python 3.9 installed and don't want to downgrade)
Cheers!
要么把python的版本降低,要么用conda安装。
我选择用conda安装,具体解决方案如下:
(1)首先输入conda install opencv-python,不过报错提示没有找到这个库,可以从它的官网去搜索。
从官网搜索opencv的结果如下:
(2)安装py-opencv,直接conda install py-opencv就可以了:
(3)等安装完成,然后import cv2测试一下,成果导入,没有报错,问题解决:
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。