【问题标题】:ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly错误:无法为使用 PEP 517 且无法直接安装的 opencv-python 构建轮子
【发布时间】:2020-12-23 04:56:48
【问题描述】:

我试图在 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

【问题讨论】:

标签: python docker opencv cmake nvidia-jetson-nano


【解决方案1】:

我遇到了同样的问题,我这样做了,

pip install --upgrade pip setuptools wheel

然后重新安装opencv,

pip install opencv-python

这对我有用

【讨论】:

    【解决方案2】:

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

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

    图像处理愉快..

    【讨论】:

    • 您好,感谢分享。我遇到了同样的错误,昨晚构建时带有参数 --platform linux/arm/v7 的 numpy 花了 11 个小时,但仍未完成。
    【解决方案3】:

    如果之后

    pip install --upgrade pip setuptools wheel
    

    你仍然有同样的错误,

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

    例如

    pip3 install opencv-python==3.4.13.47
    

    【讨论】:

      【解决方案4】:

      我遇到了类似的问题,解决它的方法不是使用python:3-alpine,而是使用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
      

      终于为我工作了。

      【讨论】:

        【解决方案5】:

        请检查您的 python 规范:

        
          - opencv -> python[
        version='
        >=2.7,<2.8.0a0
        >=3.5,<3.6.0a0
        >=3.6,<3.7.0a0
        >=3.7,<3.8.0a0']
        

        【讨论】:

          【解决方案6】:

          我通过在我的 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 by this way:

          import cv2 
          print(cv2.__version__)
          

          但是“pip list”显示的是“opencv-contrib-python 3.4.9.31”。

          【讨论】:

            猜你喜欢
            • 2020-12-31
            • 2021-02-04
            • 2020-11-01
            • 2021-04-14
            • 2020-08-05
            • 2021-02-28
            • 2020-10-16
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多