目录
- 系统环境
- 问题描述
- 问题解决
- 问题二
- 参考文章
系统环境
# macOS系统版本
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.4
BuildVersion: 18E2035
# Python版本
$ python --version
Python 3.9.13
问题描述
安装opencv-python报错,安装失败
# 安装opencv-python 的命令
pip install opencv-python
安装报错
ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
问题解决
仔细翻看报错日志,发现一个提示
unable to find utility "nasm", not a developer tool or in PATH
那么安装缺少的依赖nasm
brew reinstall nasm
再次尝试安装opencv-python,久等之后发现成功了
$ pip install opencv-python
Installing collected packages: opencv-python
Successfully installed opencv-python-4.8.1.78
很多文章说是版本问题,这个也有可能,需要视情况而定
问题二
当我再次安装指定版本的opencv-python 时候
pip install opencv-python==4.7.0.72
有新的报错
Trying 'Ninja' generator - failure
Trying 'Unix Makefiles' generator - failure
查看我之前安装的版本,发现不一样,指定上次安装的版本就安装成功了
pip install opencv-python==4.8.1.78
Successfully installed numpy-1.26.2 opencv-python-4.8.1.78
参考文章