15

我试图在 jetson nano 上的 docker 中安装 OpenCV4。它有jetpack 4.4 s os。docker 已成功创建并且 Tensorflow 正在运行,但是在使用 pip 安装 OpenCV 时显示 CMake 错误。

root@5abf405fb92d:~# pip3 install opencv-python
Collecting opencv-python
  Downloading opencv-python-4.4.0.42.tar.gz (88.9 MB)
     |████████████████████████████████| 88.9 MB 2.5 kB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from opencv-python) (1.18.4)
Building wheels for collected packages: opencv-python
  Building wheel for opencv-python (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpqpzwrofy
       cwd: /tmp/pip-install-93nxibky/opencv-python
  Complete output (9 lines):
    File "/tmp/pip-build-env-o_hualnr/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
      cmkr = cmaker.CMaker(cmake_executable)
    File "/tmp/pip-build-env-o_hualnr/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
      self.cmake_version = get_cmake_version(self.cmake_executable)
    File "/tmp/pip-build-env-o_hualnr/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
      "Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
  Traceback (most recent call last):
  
  Problem with the CMake installation, aborting build. CMake executable is cmake
  ----------------------------------------
  ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
4

6 回答 6

38

我有同样的问题,我这样做了,

pip install --upgrade pip setuptools wheel

然后再次安装opencv,

pip install opencv-python

这对我有用

于 2020-09-05T09:40:34.750 回答
4

是的..终于找到了解决方法。按照此https://github.com/mdegans/nano_build_opencv并从源代码构建并最终安装。

PS:建造可能需要一点时间,对我来说花了 10 个小时:P。

快乐的图像处理..

于 2020-09-28T12:41:27.483 回答
3

如果之后

pip install --upgrade pip setuptools wheel

你仍然有同样的错误,

您可以尝试指定要安装的旧版本的 OpenCV。

前任。

pip3 install opencv-python==3.4.13.47
于 2021-06-06T01:28:26.597 回答
1

我有一个类似的问题,为我解决的问题不是使用python:3-alpinebut python:3.8-slim. 例如:

FROM python:3.8-slim
WORKDIR /usr/src/app

RUN apt update
RUN apt -y install build-essential libwrap0-dev libssl-dev libc-ares-dev uuid-dev xsltproc
RUN apt-get update -qq \
    && apt-get install --no-install-recommends --yes \
        build-essential \
        gcc \
        python3-dev \
        mosquitto \
        mosquitto-clients


RUN pip3 install --upgrade pip setuptools wheel

RUN python3 -m pip install --no-cache-dir \
      numpy scipy matplotlib scikit-build opencv-contrib-python-headless \
      influxdb paho-mqtt configparser Pillow \
      qrcode

终于为我工作了。

于 2021-08-23T16:51:15.740 回答
0

我通过在 MacBook 中从头开始重新安装 python3 来处理它:

brew reinstall python@3.9

我还实验性地重新安装了 numpy 和 matplotlib 包。

pip3 install numpy
pip3 install matplotlib 
pip3 install opencv-contrib-python

版本:

macOS Mojave 10.14.5
Python 3.9.7
OpenCV 4.5.3

通过这种方式, OpenCV 的版本是 4.5.3 :

import cv2 
print(cv2.__version__)

但是通过“ pip list ”,它显示“opencv-contrib-python 3.4.9.31”。

于 2021-11-17T13:18:32.583 回答
0

请检查您的 python 规范:


  - opencv -> python[
version='
>=2.7,<2.8.0a0
>=3.5,<3.6.0a0
>=3.6,<3.7.0a0
>=3.7,<3.8.0a0']
于 2021-11-02T01:52:12.893 回答