当前位置:   article > 正文

ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based

error: could not build wheels for opencv-python, which is required to instal

系统环境

# macOS系统版本
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.4
BuildVersion:   18E2035

# Python版本
$ python --version
Python 3.9.13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

问题描述

安装opencv-python报错,安装失败

# 安装opencv-python 的命令
pip install opencv-python
  • 1
  • 2

安装报错

ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
  • 1

问题解决

仔细翻看报错日志,发现一个提示

unable to find utility "nasm", not a developer tool or in PATH
  • 1

那么安装缺少的依赖nasm

brew reinstall nasm
  • 1

再次尝试安装opencv-python,久等之后发现成功了

$ pip install opencv-python

Installing collected packages: opencv-python
Successfully installed opencv-python-4.8.1.78
  • 1
  • 2
  • 3
  • 4

很多文章说是版本问题,这个也有可能,需要视情况而定

问题二

当我再次安装指定版本的opencv-python 时候

pip install opencv-python==4.7.0.72
  • 1

有新的报错

Trying 'Ninja' generator - failure

Trying 'Unix Makefiles' generator - failure
  • 1
  • 2
  • 3

查看我之前安装的版本,发现不一样,指定上次安装的版本就安装成功了

pip install opencv-python==4.8.1.78

Successfully installed numpy-1.26.2 opencv-python-4.8.1.78
  • 1
  • 2
  • 3

参考文章

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/127139
推荐阅读
相关标签
  

闽ICP备14008679号