解决方法

方法一:

1. 更新pip

python -m pip install --upgrade pip

2. 更新setuptools

python -m pip install --upgrade setuptools

方法二:

检查python版本

python3 --version

若输出 Python 3.6.x:注意 opencv-contrib-python 从 4.5.5 版本后不再支持 Python 3.6,需指定旧版本(如 4.5.5.62)。

# 2. 强制安装预编译包(根据 Python 版本选择命令)
## 若 Python 3.6:安装最后支持 3.6 的版本
python3 -m pip install opencv-contrib-python==4.5.5.62

报错日志

Building wheels for collected packages: opencv-contrib-python
  Building wheel for opencv-contrib-python (pyproject.toml) ... error
  ERROR: Command errored out with exit status -4:
   command: /usr/bin/python3 /home/vb/.local/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpvh0vu93n
       cwd: /tmp/pip-install-1xepa43r/opencv-contrib-python_a09cb39e6ff5404eae96a438c219c338
  Complete output (64 lines):
  
  
  --------------------------------------------------------------------------------
  -- Trying 'Ninja' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-1xepa43r/opencv-contrib-python_a09cb39e6ff5404eae96a438c219c338/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  --
 

Logo

火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。

更多推荐