opencv安装报错解决方案

菜鸟程序员写代码5分钟,配环境5小时

这里记录一下opencv配置报错,其实之前碰到过很多遍了

情况1:安装的时候卡在这一块

python 复制代码
Building wheel for opencv-python (pyproject.toml)

解决方案:在安装指令后加--verbose

python 复制代码
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple --verbose

随后安装便会出现这种进度条

情形2:按照上述方法还是报错

报错为

python 复制代码
Failed to build opencv-python
ERROR: (ould not build wheels for opencv-python, which is required to install pyproject.toml-based projects

解决方案:可以去下载opencv-python对应的whl文件进行离线安装,但是这样比较麻烦

链接在此:

Archived: Python Extension Packages for Windows - Christoph Gohlke (uci.edu)

Links for opencv-python (tsinghua.edu.cn)

这里只需要指定opencv-python的版本进行安装就好了,关于opencv和python对应的版本

看看上面的链接

现在我的虚拟环境下是python3.6

那么只需要按照下面的指令安装

python 复制代码
pip install opencv-python==3.2.0.8 -i https://pypi.tuna.tsinghua.edu.cn/simple --verbose

可以看到已经安装好了

图中黄颜色的警告可以忽略,为了某些强迫症患者想搞清楚这个警告,我把相关解释和链接放在下面

https://peps.python.org/pep-0592/

相关推荐
金銀銅鐵1 天前
[Python] 从《千字文》中随机挑选汉字
后端·python
cup111 天前
[技术复盘] Windows Python 打包实战:Nuitka 环境踩坑总结与 CI 自动化构建全指南
python·ai·环境变量·ci·nuitka·skill
aqi002 天前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵2 天前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf2 天前
Agent 流程编排
后端·python·agent
copyer_xyf2 天前
Agent RAG
后端·python·agent
copyer_xyf2 天前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf2 天前
Agent 记忆管理
后端·python·agent
星云穿梭2 天前
用Python写一个带图形界面的学生管理系统——完整教程
python