Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

ERROR: Could not build wheels for opencv-python which > use PEP 517 and cannot be installed directly

Ask Question i have a very equal problem to the problem shown here ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly .

I'm using a jetson Nano (ubuntu 18.04).

Error

Building wheel for opencv-python (PEP 517) ... error ERROR: Command errored out with exit status 1: command: /home/christopher/heartkillayolotest2/heartkillayolotest2/bin/python /home/christopher/heartkillayolotest2/heartkillayolotest2/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpwort0shc cwd: /tmp/pip-install-g68zdlf0/opencv-python Complete output (9 lines): File "/tmp/pip-build-env-1b_l6sbo/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup cmkr = cmaker.CMaker(cmake_executable) File "/tmp/pip-build-env-1b_l6sbo/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-1b_l6sbo/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

I tried this to solve the problem but it did not help:

(heartkillayolotest2)christopher@ccz:~/heartkillayolotest2/heartkillayolotest2$ pip3 install --upgrade pip Requirement already up-to-date: pip in ./lib/python3.6/site-packages (20.2.3)

(heartkillayolotest2) christopher@ccz:~/heartkillayolotest2/heartkillayolotest2/yolo-v3$ pip3 install --upgrade pip Requirement already up-to-date: pip in /home/christopher/heartkillayolotest2/heartkillayolotest2/lib/python3.6/site-packages (20.2.3)

Unfortunatelly the error still occurs.

Can somebody help me?

After trying most of the suggested options in this and other threads, including the most popular: trying 'pip install --upgrade pip setuptools wheel' before installing openCV.

What finally did the trick for me was:

pip install --no-use-pep517 opencv-python

(macOS)

You are using Jetson Nano which is a arm64 board. There are no pre-built wheels for ARM architecture for opencv-python. Due to this, pip will attempt to build the package from sources. This will not succeed, because there is a known issue with the cmake dependency which is needed for the build. You can check these issues for more info:

  • cmake: https://github.com/scikit-build/cmake-python-distributions/issues/115
  • opencv-python: https://github.com/skvark/opencv-python/issues/366
  • Currently, you can't build OpenCV's Python bindings via the opencv-python package on ARM architecture systems due to the cmake issue. Meanwhile you can follow the official OpenCV documentation to install OpenCV Python bindings from source: https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html

    Note that the accepted answer is not correct. pip will install the build dependencies automatically (and cython is not needed) given that your pip version is greater than 19.0.

    As of Feb 2021 it seems that the issue for arm64 is [github.com/opencv/opencv-python/issues/…. Also, upgrading pip seemed to have been key for me. – Frank Podborski May 17, 2022 at 7:32
    $ sudo apt-get install python-opencv
    

    After that I had to install opencv again. I followed the instructions of the website you gave me (https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html).

    I also got the same link in a python-forum (german) (https://www.python-forum.de/viewtopic.php?f=2&t=49781&p=373939#p373939). Just for the case that somebody wants to read it in german.

    The problem is with cmake and python. Python need skbuild and cython for this job.

    pip3 install scikit-build
    pip3 install cython
    

    and then

    pip3 install opencv-python
    

    Unfortunatelly I was glad to early, because the error still occurs.

    I did the following (perhaps these steps will help someone else). But for me nothing solved the problem. Is there something else I can do?

    pip install cython

    (yolov3Tensorflow) christopher@ccz:~/TensorFlow_2_x_YOLOv3$ pip install cython Collecting cython Using cached Cython-0.29.21-py2.py3-none-any.whl (974 kB) Installing collected packages: cython Successfully installed cython-0.29.21 WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available. You should consider upgrading via the '/home/christopher/yolov3Tensorflow/bin/python -m pip install --upgrade pip' command.

    pip install --upgrade pip setuptools wheel

    (yolov3Tensorflow) christopher@ccz:~/TensorFlow_2_x_YOLOv3$ pip install --upgrade pip setuptools wheel Collecting pip Using cached pip-20.2.3-py2.py3-none-any.whl (1.5 MB) Collecting setuptools Using cached setuptools-50.3.0-py3-none-any.whl (785 kB) Collecting wheel
    Using cached wheel-0.35.1-py2.py3-none-any.whl (33 kB) Installing collected packages: pip, setuptools, wheel Attempting uninstall: pip Found existing installation: pip 20.1.1 Uninstalling pip-20.1.1: Successfully uninstalled pip-20.1.1 Attempting uninstall: setuptools Found existing installation: setuptools 47.1.1 Uninstalling setuptools-47.1.1: Successfully uninstalled setuptools-47.1.1 Attempting uninstall: wheel Found existing installation: wheel 0.34.2 Uninstalling wheel-0.34.2: Successfully uninstalled wheel-0.34.2 Successfully installed pip-20.2.3 setuptools-50.3.0 wheel-0.35.1

    pip3 install scikit-build

    (yolov3Tensorflow) christopher@ccz:~/TensorFlow_2_x_YOLOv3$ pip3 install scikit-build Collecting scikit-build Using cached scikit_build-0.11.1-py2.py3-none-any.whl (72 kB) Collecting packaging Using cached packaging-20.4-py2.py3-none-any.whl (37 kB) Collecting distro Using cached distro-1.5.0-py2.py3-none-any.whl (18 kB) Requirement already satisfied: wheel>=0.29.0 in /home/christopher/yolov3Tensorflow/lib/python3.6/site-packages (from scikit-build) (0.35.1) Requirement already satisfied: setuptools>=28.0.0; python_version >= "3" in /home/christopher/yolov3Tensorflow/lib/python3.6/site-packages (from scikit-build) (50.3.0) Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from packaging->scikit-build) (1.14.0) Requirement already satisfied: pyparsing>=2.0.2 in /usr/lib/python3/dist-packages (from packaging->scikit-build) (2.2.0) Installing collected packages: packaging, distro, scikit-build Successfully installed distro-1.5.0 packaging-20.4 scikit-build-0.11.1

    pip3 install --upgrade pip

    (yolov3Tensorflow) christopher@ccz:~/TensorFlow_2_x_YOLOv3$ pip3 install --upgrade pip Requirement already up-to-date: pip in /home/christopher/yolov3Tensorflow/lib/python3.6/site-packages (20.2.3)

    pip3 install cmake

    (yolov3Tensorflow) christopher@ccz:~/TensorFlow_2_x_YOLOv3$ pip3 install cmake Collecting cmake Using cached cmake-3.18.2.post1-py3-none-manylinux2014_aarch64.whl (15.2 MB) Installing collected packages: cmake Successfully installed cmake-3.18.2.post1

    AND THIS IS THE ERROR AGAIN

    (yolov3Tensorflow) christopher@ccz:~/TensorFlow_2_x_YOLOv3$ pip install opencv-python Collecting opencv-python Using cached opencv-python-4.4.0.44.tar.gz (88.9 MB) 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.16.1) Building wheels for collected packages: opencv-python Building wheel for opencv-python (PEP 517) ... error
    ERROR: Command errored out with exit status 1: command: /home/christopher/yolov3Tensorflow/bin/python /home/christopher/yolov3Tensorflow/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpg3wn763c cwd: /tmp/pip-install-spfl5_2j/opencv-python Complete output (9 lines): File "/tmp/pip-build-env-3np44f8c/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup cmkr = cmaker.CMaker(cmake_executable) File "/tmp/pip-build-env-3np44f8c/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-3np44f8c/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

    I have no idea what to do know?

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.