Skip to content

ERROR: Failed building wheel for opencv-python: [ FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-armv7l-3.9/cmake-install/python/cv2/config-3.py' ] #814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
UncleBob125 opened this issue Mar 7, 2023 · 41 comments
Assignees
Labels
Milestone

Comments

@UncleBob125
Copy link

Expected behaviour

I tried to install opencv-python in my virtual environment and was expecting the opencv-python library v4.7.0.72 to be installed succesfully.
Even after multiple tries and trying different solutions/workarounds found online, nothing seems to help.

Actual behaviour

The build runs for +-3 hours, goes to 100% and then later on fails during installation phase of the project.
Following error is being returned:
FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-armv7l-3.9/cmake-install/python/cv2/config-3.py'
error: subprocess-exited-with-error

Steps to reproduce

  • pip3 install --upgrade pip
result
(venv) username@raspberrypi:~/Desktop/myApp $ pip3 install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (23.0.1)
  • pip3 install opencv-python --verbose
result
(venv) username@raspberrypi:~/Desktop/MyApp $ pip3 install opencv-py                                                                                                                                                             thon --verbose
Using pip 23.0.1 from /home/username/Desktop/MyApp/venv/lib/python3.                                                                                                                                                             9/site-packages/pip (python 3.9)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting opencv-python
  Using cached opencv-python-4.7.0.72.tar.gz (91.1 MB)
  Running command pip subprocess to install build dependencies
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple,                                                                                                                                                              https://www.piwheels.org/simple
  Ignoring numpy: markers 'python_version == "3.6" and platform_machine != "aarc                                                                                                                                                             h64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarc                                                                                                                                                             h64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.8" and platform_machine != "aarc                                                                                                                                                             h64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "linux" a                                                                                                                                                             nd platform_machine == "aarch64"' don't match your environment
  Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "darwin"                                                                                                                                                              and platform_machine == "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.10" and platform_system != "Darw                                                                                                                                                             in"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.10" and platform_system == "Darw                                                                                                                                                             in"' don't match your environment
  Ignoring numpy: markers 'python_version >= "3.11"' don't match your environmen                                                                                                                                                             t
  Collecting setuptools==59.2.0
    Using cached https://www.piwheels.org/simple/setuptools/setuptools-59.2.0-py                                                                                                                                                             3-none-any.whl (952 kB)
  Collecting wheel==0.37.0
    Using cached https://www.piwheels.org/simple/wheel/wheel-0.37.0-py2.py3-none                                                                                                                                                             -any.whl (35 kB)
  Collecting cmake>=3.1
    Using cached https://www.piwheels.org/simple/cmake/cmake-3.25.2-cp39-cp39-linux_armv7l.whl (17.3 MB)
  Collecting pip
    Using cached https://www.piwheels.org/simple/pip/pip-23.0.1-py3-none-any.whl (2.1 MB)
  Collecting scikit-build>=0.13.2
    Using cached https://www.piwheels.org/simple/scikit-build/scikit_build-0.16.7-py3-none-any.whl (79 kB)
  Collecting numpy==1.19.3
    Using cached https://www.piwheels.org/simple/numpy/numpy-1.19.3-cp39-cp39-linux_armv7l.whl (10.5 MB)
  Collecting packaging
    Using cached https://www.piwheels.org/simple/packaging/packaging-23.0-py3-none-any.whl (42 kB)
  Collecting distro
    Using cached https://www.piwheels.org/simple/distro/distro-1.8.0-py3-none-any.whl (20 kB)
  Installing collected packages: cmake, wheel, setuptools, pip, packaging, numpy, distro, scikit-build
  ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
  matplotlib 3.7.1 requires numpy>=1.20, but you have numpy 1.19.3 which is incompatible.
  Successfully installed cmake-3.25.2 distro-1.8.0 numpy-1.19.3 packaging-23.0 pip-23.0.1 scikit-build-0.16.7 setuptools-59.2.0 wheel-0.37.0
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  running egg_info
  writing opencv_python.egg-info/PKG-INFO
  writing dependency_links to opencv_python.egg-info/dependency_links.txt
  writing requirements to opencv_python.egg-info/requires.txt
  writing top-level names to opencv_python.egg-info/top_level.txt
  reading manifest file 'opencv_python.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*' under directory 'opencv_contrib'
  adding license file 'LICENSE-3RD-PARTY.txt'
  adding license file 'LICENSE.txt'
  writing manifest file 'opencv_python.egg-info/SOURCES.txt'
  Getting requirements to build wheel ... done
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  creating /tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info
  writing /tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/PKG-INFO
  writing dependency_links to /tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/dependency_links.txt
  writing requirements to /tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/requires.txt
  writing top-level names to /tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/top_level.txt
  writing manifest file '/tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/SOURCES.txt'
  reading manifest file '/tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*' under directory 'opencv_contrib'
  adding license file 'LICENSE-3RD-PARTY.txt'
  adding license file 'LICENSE.txt'
  writing manifest file '/tmp/pip-modern-metadata-6qbzchkt/opencv_python.egg-info/SOURCES.txt'
  creating '/tmp/pip-modern-metadata-6qbzchkt/opencv_python.dist-info'
  adding license file "LICENSE-3RD-PARTY.txt" (matched pattern "LICEN[CS]E*")
  adding license file "LICENSE.txt" (matched pattern "LICEN[CS]E*")
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.17.3 in ./venv/lib/python3.9/site-packages (from opencv-python) (1.24.2)
Building wheels for collected packages: opencv-python
  Running command Building wheel for opencv-python (pyproject.toml)
  patching file opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp


  --------------------------------------------------------------------------------
  -- 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-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'Unix Makefiles' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  -- The C compiler identification is GNU 10.2.1
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- The CXX compiler identification is GNU 10.2.1
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/_cmake_test_compile/build
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Unix Makefiles' generator - success
  --------------------------------------------------------------------------------

  Configuring Project
    Working directory:
      /tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/_skbuild/linux-armv7l-3.9/cmake-build
    Command:
      /tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/cmake/data/bin/cmake /tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/opencv -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/_skbuild/linux-armv7l-3.9/cmake-install -DPYTHON_VERSION_STRING:STRING=3.9.2 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/home/username/Desktop/MyApp/venv/bin/python -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPYTHON_LIBRARY:PATH=/usr/lib/arm-linux-gnueabihf/libpython3.9.so -DPython_EXECUTABLE:PATH=/home/username/Desktop/MyApp/venv/bin/python -DPython_ROOT_DIR:PATH=/home/username/Desktop/MyApp/venv -DPython_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPython_FIND_REGISTRY:STRING=NEVER -DPython3_EXECUTABLE:PATH=/home/username/Desktop/MyApp/venv/bin/python -DPython3_ROOT_DIR:PATH=/home/username/Desktop/MyApp/venv -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPython3_FIND_REGISTRY:STRING=NEVER -DPYTHON3_EXECUTABLE=/home/username/Desktop/MyApp/venv/bin/python -DPYTHON3_INCLUDE_DIR=/usr/include/python3.9 -DPYTHON3_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.9.so -DBUILD_opencv_python3=ON -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DOPENCV_PYTHON3_INSTALL_PATH=python -DINSTALL_CREATE_DISTRIB=ON -DBUILD_opencv_apps=OFF -DBUILD_opencv_freetype=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_DOCS=OFF -DPYTHON3_LIMITED_API=ON -DBUILD_OPENEXR=ON -DCMAKE_BUILD_TYPE:STRING=Release

  -- The CXX compiler identification is GNU 10.2.1
  -- The C compiler identification is GNU 10.2.1
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- ocv_init_download: OpenCV source tree is not fetched as git repository. 3rdparty resources will be downloaded from github.com by default.
  -- Detected processor: armv7l
  -- Found PythonInterp: /home/username/Desktop/MyApp/venv/bin/python (found suitable version "3.9.2", minimum required is "2.7")
  CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
    CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:

    PYTHON_EXECUTABLE=/home/username/Desktop/MyApp/venv/bin/python

    PYTHON_VERSION_STRING=3.9.2

    Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
    or environment variables

  Call Stack (most recent call first):
    cmake/OpenCVDetectPython.cmake:271 (find_python)
    CMakeLists.txt:643 (include)


  -- Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
      Reason given by package:
          Interpreter: Wrong major version for the interpreter "/bin/python"

  -- Found PythonInterp: /home/username/Desktop/MyApp/venv/bin/python (found suitable version "3.9.2", minimum required is "3.2")
  -- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython3.9.so (found suitable exact version "3.9.2")
  Traceback (most recent call last):
    File "/tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 22, in <module>
      from . import multiarray
    File "/tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in <module>
      from . import overrides
    File "/tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in <module>
      from numpy.core._multiarray_umath import (
  ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/numpy/__init__.py", line 140, in <module>
      from . import core
    File "/tmp/pip-build-env-m8axndlg/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
      raise ImportError(msg)
  ImportError:

  IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

  Importing the numpy C-extensions failed. This error can happen for
  many reasons, often due to issues with your setup or how NumPy was
  installed.

  We have compiled some common reasons and troubleshooting tips at:

      https://numpy.org/devdocs/user/troubleshooting-importerror.html

  Please note and check the following:

    * The Python version is: Python3.9 from "/home/username/Desktop/MyApp/venv/bin/python"
    * The NumPy version is: "1.19.3"

  and make sure that they are the versions you expect.
  Please carefully study the documentation linked above for further help.

  Original error was: libcblas.so.3: cannot open shared object file: No such file or directory

  -- Looking for ccache - not found
 *** cut out ***
  -- General configuration for OpenCV 4.7.0 =====================================
  --   Version control:               unknown
  --
  --   Platform:
  --     Timestamp:                   2023-03-07T08:35:01Z
  --     Host:                        Linux 5.15.61-v7+ armv7l
  --     CMake:                       3.25.2
  --     CMake generator:             Unix Makefiles
  --     CMake build tool:            /usr/bin/gmake
  --     Configuration:               Release
  --
  --   CPU/HW features:
  --     Baseline:
  --       requested:                 DETECT
  --
  --   C/C++:
  --     Built as dynamic libs?:      NO
  --     C++ standard:                11
  --     C++ Compiler:                /usr/bin/c++  (ver 10.2.1)
  --     C++ flags (Release):         -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
  --     C++ flags (Debug):           -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
  --     C Compiler:                  /usr/bin/cc
  --     C flags (Release):           -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-psabi -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
  --     C flags (Debug):             -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-psabi -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
  --     Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
  --     Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
  --     ccache:                      NO
  --     Precompiled headers:         NO
  --     Extra dependencies:          /usr/lib/arm-linux-gnueabihf/libpng.so /usr/lib/arm-linux-gnueabihf/libz.so dl m pthread rt
  --     3rdparty dependencies:       libprotobuf ade ittnotify libjpeg-turbo libwebp libtiff libopenjp2 IlmImf quirc
  --
  --   OpenCV modules:
  --     To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching video videoio
  --     Disabled:                    world
  --     Disabled by dependency:      -
  --     Unavailable:                 java python2 python3 ts
  --     Applications:                -
  --     Documentation:               NO
  --     Non-free algorithms:         NO
  --
  --   GUI:                           NONE
  --     GTK+:                        NO
  --     VTK support:                 NO
  --
  --   Media I/O:
  --     ZLib:                        /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.11)
  --     JPEG:                        libjpeg-turbo (ver 2.1.3-62)
  --     WEBP:                        build (ver encoder: 0x020f)
  --     PNG:                         /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.6.37)
  --     TIFF:                        build (ver 42 - 4.2.0)
  --     JPEG 2000:                   build (ver 2.4.0)
  --     OpenEXR:                     build (ver 2.3.0)
  --     HDR:                         YES
  --     SUNRASTER:                   YES
  --     PXM:                         YES
  --     PFM:                         YES
  --
  --   Video I/O:
  --     DC1394:                      NO
  --     FFMPEG:                      NO
  --       avcodec:                   NO
  --       avformat:                  NO
  --       avutil:                    NO
  --       swscale:                   NO
  --       avresample:                NO
  --     GStreamer:                   NO
  --     v4l/v4l2:                    YES (linux/videodev2.h)
  --
  --   Parallel framework:            pthreads
  --
  --   Trace:                         YES (with Intel ITT)
  --
  --   Other third-party libraries:
  --     Lapack:                      NO
  --     Eigen:                       NO
  --     Custom HAL:                  NO
  --     Protobuf:                    build (3.19.1)
  --
  --   OpenCL:                        YES (no extra features)
  --     Include path:                /tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/opencv/3rdparty/include/opencl/1.2
  --     Link libraries:              Dynamic load
  --
  --   Python 3:
  --     Interpreter:                 /home/username/Desktop/MyApp/venv/bin/python (ver 3.9.2)
  --     Libraries:                   NO
  --     numpy:                       NO (Python3 wrappers can not be generated)
  --     install path:                -
  --
  --   Python (for build):            /home/username/Desktop/MyApp/venv/bin/python
  --
  --   Java:
  --     ant:                         /bin/ant (ver 1.10.9)
  --     JNI:                         NO
  --     Java wrappers:               NO
  --     Java tests:                  NO
  --
  --   Install to:                    /tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/_skbuild/linux-armv7l-3.9/cmake-install
  -- -----------------------------------------------------------------
  --
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /tmp/pip-install-6_x1lqim/opencv-python_5f225b8f191e4bdf9b9078bacd8de511/_skbuild/linux-armv7l-3.9/cmake-build
  [  0%] Built target opencv_dnn_plugins

--- Cut out between 1 & 99% since comment is too longer otherwise ---

 [100%] Built target opencv_gapi
  Install the project...
  -- Install configuration: "Release"

 ****Cut out****

Copying files from CMake output
  Traceback (most recent call last):
    File "/home/username/Desktop/MyApp/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/username/Desktop/MyApp/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/username/Desktop/MyApp/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-n0_0bzbu/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 230, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "/tmp/pip-build-env-n0_0bzbu/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-n0_0bzbu/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 267, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-n0_0bzbu/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 512, in <module>
      main()
    File "setup.py", line 262, in main
      skbuild.setup(
    File "/tmp/pip-build-env-n0_0bzbu/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 673, in setup
      _classify_installed_files(
    File "setup.py", line 398, in _classify_installed_files_override
      with open('%spython/cv2/config-%s.py'
  FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-armv7l-3.9/cmake-install/python/cv2/config-3.py'
  error: subprocess-exited-with-error

  × Building wheel for opencv-python (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/username/Desktop/MyApp/venv/bin/python /home/username/Desktop/MyApp/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpnv5v7b7u
  cwd: /tmp/pip-install-ohiu737z/opencv-python_cc146731452e41c0bfc732e69dc17b71
  Building wheel for opencv-python (pyproject.toml) ... error
  ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects

 

System

  • Raspberry Pi Model 3B+
  • Ubuntu v18.04
  • Linux 5.15.61-v7+
  • Architecture: Arm
  • Python v3.9

What I've tried so far

  • Upgrading entire Linux system
  • Reinstalling Python
  • Reinstalling pip
  • Upgrading pip
  • Setting version explicitly to v4.7.0.72 ( using == operator )
  • Setting version explicitly to v4.7.0.68
@billni
Copy link

billni commented Mar 9, 2023

I had the same problem. Try it "sudo apt install python3-opencv"

@UncleBob125
Copy link
Author

I had the same problem. Try it "sudo apt install python3-opencv"

Hi billni, thanks for your answer.

I've tried that as well, but that installs it globally and not in my virtual environment.
I need it to be in my virtual environment, since I want to package the application with all dependencies into single binary from that virtual environment.

@asmorkalov asmorkalov self-assigned this Mar 9, 2023
@asmorkalov
Copy link
Collaborator

It looks like I was able to reproduce the issue with my Pi 3b. Will take a look if I can propose some workaround before the next release.

@ghost
Copy link

ghost commented Mar 14, 2023

It looks like I was able to reproduce the issue with my Pi 3b. Will take a look if I can propose some workaround before the next release.

Cheers, much looking forward to this

@asmorkalov
Copy link
Collaborator

config-XXX.py is named differently depending on LIMITED_API option. https://github.com/opencv/opencv/blob/4.x/modules/python/common.cmake#L210
CI build enabled LIMITED_API by default and it works well.
You can add -DPYTHON3_LIMITED_API=ON to CMake options to work around the issue.
See https://github.com/opencv/opencv-python/blob/4.x/setup.py#L179 and https://github.com/opencv/opencv-python/blob/4.x/setup.py#L251

@asmorkalov asmorkalov added the bug label Mar 14, 2023
@ghost
Copy link

ghost commented Mar 14, 2023

config-XXX.py is named differently depending on LIMITED_API option. https://github.com/opencv/opencv/blob/4.x/modules/python/common.cmake#L210
CI build enabled LIMITED_API by default and it works well.
You can add -DPYTHON3_LIMITED_API=ON to CMake options to work around the issue.
See https://github.com/opencv/opencv-python/blob/4.x/setup.py#L179 and https://github.com/opencv/opencv-python/blob/4.x/setup.py#L251

Thank you very much. So its simply pip3 install opencv-python -DPYTHON3_LIMITED_API=ON --verbose

Or is that completely wrong?

@asmorkalov
Copy link
Collaborator

Use environment variable CMAKE_ARGS to define extra CMake arguments.

@asmorkalov
Copy link
Collaborator

Fixed in #820

@ghost
Copy link

ghost commented Mar 17, 2023

Fixed in #820

Its still coming up with the error?

@ghost
Copy link

ghost commented Mar 17, 2023

I can see your little eyes looking! When you said fixed I presumed I would just run the install again and it should work?! A little more help is needed please, Alexander @asmorkalov :) I have spent weeks trying to get OpenCV working and every guide I have tried has failed! I don't see how it's so bloody hard to install?!

All I'm looking to do is run the NDVI script using my RPI 3B+ and NOIR V3 camera! I don't know if it helps but I could instal OpenCV on my Unraid server and have the feed from the Pi go there and the server does all the hard work. At the end of the day, my server is running Home Assistant in a VM but I need the Pi's NOIR camera with the blue filter over the lens.

@skvark
Copy link
Member

skvark commented Mar 17, 2023

Obviously, the new version that would include the bug fix hasn't been released to the Python package index since the fix was just merged into this repository. You'll have to wait for a new release, or clone this repository and do a manual build.

@ghost
Copy link

ghost commented Mar 17, 2023 via email

@UncleBob125
Copy link
Author

UncleBob125 commented Mar 18, 2023

Thanks for the fix @asmorkalov !
Is it correct this should now be available in the opencv-python-rolling deployment package?
I tried to install this by using "pip install opencv-python-rolling==4.7.0.20230318"
But it seems te version can't be found.
On piwheels.org it says the build is skipped? => https://piwheels.org/project/opencv-python-rolling/
Should I take a different approach?
Sorry if this is a dumb question, i'm pretty new to this.

Thanks in advance!

@asmorkalov
Copy link
Collaborator

Rolling releases are broken for today. I'm working on it right now. I'll let you know, when you can try.

@ghost
Copy link

ghost commented Mar 29, 2023

Rolling releases are broken for today. I'm working on it right now. I'll let you know, when you can try.

Any update? @asmorkalov Cheers

@clintlombard
Copy link

I had no luck with #820, but pinning the scikit-build version in pyproject.toml to 0.17.1 everything worked again (without this 0.17.3 is installed):

---  "scikit-build>=0.13.2",
+++  "scikit-build==0.17.1",

I tested 0.17.2 and it fails with

AttributeError: 'NoneType' object has no attribute 'replace'

This was fixed in 0.17.3, but there seems to be some other change in there that's breaking things. Is there any reason to not pin this version for the builds?

@rpigott
Copy link

rpigott commented May 23, 2023

This build failure is still present with python3.11. It appears to be caused by #835 — the incompatible numpy version apparently disables the python bindings since I can see that "install path" is omitted from the cmake version string no matter the value of -DCMAKE_PYTHON3_INSTALL_PATH. Updating numpy to a compatible version allowed me to build a wheel with 3.11. CI doesn't have this issue because of the TEST_DEP_LATEST override.

Should be fixed by #839.

@asmorkalov
Copy link
Collaborator

The issue closed. OpenCV-Python 4.8.0 with the issue fix will be release in a couple of days.

@WoodieDudy
Copy link

WoodieDudy commented Oct 15, 2023

@asmorkalov
I tried to build opencv-python package into docker and got same error. How can I handle it?

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install --no-install-recommends -y build-essential gcc software-properties-common curl && \
    add-apt-repository -y ppa:deadsnakes/ppa && \
    apt-get install --no-install-recommends -y python3.10 python3.10-dev python3-pip python3-setuptools python3.10-distutils python3.10-venv

WORKDIR /venv
RUN python3.10 -m venv /venv
ENV PATH="/venv/bin:$PATH"

RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

RUN pip3.10 install --upgrade pip
RUN python3.10 -m pip install --upgrade wheel setuptools requests

ENV OPENCV_VERSION=4.8.1

RUN apt-get install -y \
    cmake \
    libjack-jackd2-dev \
    libmp3lame-dev \
    libopencore-amrnb-dev \
    libopencore-amrwb-dev \
    libsdl1.2-dev \
    libtheora-dev \
    libva-dev \
    libvdpau-dev \
    libvorbis-dev \
    libx11-dev \
    libxfixes-dev \
    libxvidcore-dev \
    texi2html \
    zlib1g-dev \
    wget \
    unzip \
    yasm \
    pkg-config \
    libswscale-dev \
    libtbb2 \
    libtbb-dev \
    libjpeg-dev \
    libpng-dev \
    libtiff-dev \
    libavformat-dev \
    libpq-dev \
    x264 \
    libx264-dev \
    ffmpeg \
    git

WORKDIR /opencv

RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
    unzip ${OPENCV_VERSION}.zip && \
    mkdir opencv-${OPENCV_VERSION}/build

WORKDIR /opencv/opencv-${OPENCV_VERSION}/build

RUN cmake \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D BUILD_TESTS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D BUILD_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D INSTALL_C_EXAMPLES=OFF \
    -D BUILD_opencv_python2=OFF \
    -D BUILD_opencv_python3=ON \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D OPENCV_PC_FILE_NAME=opencv.pc \
    -D PYTHON_EXECUTABLE=/usr/bin/python3.10 \
    -D OPENCV_PYTHON3_INSTALL_PATH=/venv/lib/python3.10/site-packages \
    -D BUILD_opencv_java=OFF \
    -D WITH_CUDA=OFF \
    -D WITH_CUDNN=OFF \
    -D WITH_OPENCL=OFF \
    -D WITH_OPENMP=OFF \
    -D WITH_TBB=OFF \
    -D WITH_IPP=OFF \
    -D WITH_1394=OFF \
    -D WITH_FFMPEG=ON \
    -D WITH_GSTREAMER=OFF \
    -D WITH_GSTREAMER_0_10=OFF \
    -D WITH_GTK=OFF \
    -D WITH_JASPER=OFF \
    -D WITH_JPEG=ON \
    -D WITH_OPENEXR=OFF \
    -D WITH_PNG=ON \
    -D WITH_TIFF=ON \
    -D WITH_WEBP=OFF \
    -D WITH_V4L=OFF \
    -D WITH_VTK=OFF \
    -D WITH_EIGEN=OFF \
    -D WITH_PROTOBUF=OFF \
    -D WITH_GDCM=OFF \
    -D WITH_OPENJPEG=OFF \
    -D WITH_OPENNI=OFF \
    -D WITH_OPENNI2=OFF \
    -D WITH_PVAPI=OFF \
    -D WITH_ARAVIS=OFF \
    -D WITH_GIGEAPI=OFF \
    -D WITH_QT=OFF \
    -D WITH_OPENGL=OFF \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D BUILD_NEW_PYTHON_SUPPORT=ON \
    -D HAVE_opencv_python3=ON \
    -D BUILD_opencv_gapi=ON \
    -D PYTHON3_LIMITED_API=ON \
    .. \
    && make -j$(nproc) \
    && make install

WORKDIR /opencv
RUN git clone https://github.com/opencv/opencv-python.git
WORKDIR /opencv/opencv-python
RUN python3.10 -m pip install scikit-build
RUN python3.10 setup.py bdist_wheel

Build output:

Copying files from CMake output
Traceback (most recent call last):
  File "/opencv/opencv-python/setup.py", line 535, in <module>
    main()
  File "/opencv/opencv-python/setup.py", line 267, in main
    skbuild.setup(
  File "/venv/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
    _classify_installed_files(
  File "/opencv/opencv-python/setup.py", line 409, in _classify_installed_files_override
    with open(config_py, 'w') as opencv_init_config:
FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-x86_64-3.10/cmake-install/python/cv2/config-3.py'

@Kunjesh07
Copy link

I had the same problem. Try it "sudo apt install python3-opencv"

This worked for me

@asmorkalov
Copy link
Collaborator

"sudo apt install python3-opencv"

It's bad idea. The command installs yet another OpenCV-Python instance of some old version provided by Linux distribution. Doing that you get a salad of several instances of OpenCV that is loaded in inpredictable order. You can switch to distro-provided OpenCV Python, but all other instanced should be removed first.

@WoodieDudy
Copy link

sudo apt install python3-opencv

Anyway that didn't help

@ChanJoon
Copy link

sudo apt install python3-opencv

Anyway that didn't help

How did you solve your problem? I encountered similar issue on RPi 4B

FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-aarch64-3.9/cmake-install/python/cv2/config-3.py'
  error: subprocess-exited-with-error
  
  × Building wheel for opencv-python (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python3 /home/pbs/.local/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmp8g9__46_
  cwd: /tmp/pip-install-vlokyin2/opencv-python_82696fa637964183835fb00d04c812e9
  Building wheel for opencv-python (pyproject.toml) ... error
  ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects

@WoodieDudy
Copy link

Probably, I installed numpy before running setup.py.
Also here you can check my working Dockerfile for building wheel

@ChanJoon
Copy link

Probably, I installed numpy before running setup.py. Also here you can check my working Dockerfile for building wheel

Thank you for your reply! The Dockerfile looks not much different from #814 (comment)

Did you find the reason of this error message?

Traceback (most recent call last):
  File "/opencv/opencv-python/setup.py", line 535, in <module>
    main()
  File "/opencv/opencv-python/setup.py", line 267, in main
    skbuild.setup(
  File "/venv/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
    _classify_installed_files(
  File "/opencv/opencv-python/setup.py", line 409, in _classify_installed_files_override
    with open(config_py, 'w') as opencv_init_config:
FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-x86_64-3.10/cmake-install/python/cv2/config-3.py'

@ChanJoon
Copy link

Ah I see. you said installing numpy before running setup.py

@goingalong
Copy link

Have I missed it, it there a solution to this problem? All I am wanting is to install DVR-Scan on a headless Pi.

@ChanJoon
Copy link

Have I missed it, it there a solution to this problem? All I am wanting is to install DVR-Scan on a headless Pi.

I resolved the issue with building opencv-python source manually. (latest release one)

@goingalong
Copy link

ChanJoon, thank you for your suggestion.
Rather than go down the rabbit hole of a manual installation I searched for "installing opencv rpi" and found the following comment:

The standard command to install opencv is pip install opencv-contrib-python but don’t immediately run this (!) as it will try to install the latest versio of OpenCV, which is not always fully functional on the Raspberry Pi. Furthermore, the installation may take a very long time. Therefore I recommend to run the below command that installs the latest known working version. Here I use 4.5.3.56 but it could be that already a newer stable version is available

Using instructions on this site:
https://singleboardblog.com/install-python-opencv-on-raspberry-pi/

and after installing the prerequisites I used this command:
pip install opencv-python-headless==4.5.3.56
This installed opencv very quickly, but obviously for an earlier version.

I know that this thread is not about DVR-Scan but to install it I then used:
pip install dvr-scan[opencv-headless]

Progress at least.

@johnteslade
Copy link

We had this issue recently and found it was due to cmake not creating the opencv python library cv2.abi3.so. Check back on the build logs from cmake and look at the lines that say:

--   OpenCV modules:
--     To be built:

make sure that python3 is in this list (as it likely isn't). Further up in the logs I could then see the following error:

-- Found PythonInterp: /venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.2") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so (found suitable exact version "3.10.13") 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

For me the fix was just to install numpy first. Change the Dockerfile in #814 (comment) to install it before build:

- RUN python3.10 -m pip install scikit-build
+ RUN python3.10 -m pip install scikit-build numpy

@goatzillax
Copy link

Was this supposed to be fixed? I'm still getting the exact same fail signature as in the subject line with opencv-python-headless 4.9 and 4.8 and Raspbian Bullseye.

@NasaKHw
Copy link

NasaKHw commented Feb 7, 2024

consider installing python3-dev or python3-devel using yum it worked for me with opencv-python-headless when it cant build wheel

@goatzillax
Copy link

goatzillax commented Feb 8, 2024

Hrm, nope.

dpkg --list | grep python3-dev
ii libpython3-dev:armhf 3.9.2-3 armhf header files and a static library for Python (default)
ii python3-dev 3.9.2-3 armhf header files and a static library for Python (default)

6 hours later...

    File "setup.py", line 411, in _classify_installed_files_override
      with open(config_py, 'w') as opencv_init_config:
  FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-armv7l-3.9/cmake-install/python/cv2/config-3.py'

Pretty much always the same thing; this was with 4.9.0.80.

@asmorkalov asmorkalov reopened this Feb 8, 2024
@kajalsinha
Copy link

I also have the same error. I am trying to install it on raspberry pi 3

@patrickelectric
Copy link

patrickelectric commented Apr 19, 2024

Having the same error while build armv7 with docker python:3.11.5-bookworm
I did try running with: CMAKE_ARGS=-DPYTHON3_LIMITED_API=ON pip install opencv-python-headless --verbose without success

@asmorkalov asmorkalov added this to the 4.10.0 milestone Apr 19, 2024
@patrickelectric
Copy link

Same problem building it in a docker buildx crosscompiling to arm/v7 and compiling in a raspberry directly.

@VoidMaster23
Copy link

Has anyone managed to get this working? I'm having the same issue on my raspberry pi

@ZipovUA
Copy link

ZipovUA commented Aug 21, 2024

Have the same problem on raspberry pi 5

@unisun2
Copy link

unisun2 commented Aug 24, 2024

try this.

pip install numpy==1.23.5

@rcomyn
Copy link

rcomyn commented Sep 1, 2024

I was able to install OpenCV on a RaspberryPi 3B+ on Bullseye using the process described here:
https://www.orionrobots.co.uk/2024/02/20/installing-opencv-and-numpy-learnrobotics.html

@AntzInThePantz
Copy link

AntzInThePantz commented Apr 18, 2025

I had a similar Problem on my Raspberry Pi 4. For me the numpy installation missed some requirements. I could install numpy with pip but when i tried to import numpy in a python file i did get an error that told me "libopenblas.so.0: cannot open shared object file: No such file or directory". So i installed it via "sudo apt-get install libopenblas-dev". After that i installed numpy with pip and then the build worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests