'opencv-contrib-python build fails due to skbuild or Cmake error

My setup:

MacOS, Mojave, Mac Mini A1993 (2018)

Python 3.7.4, virtual environment

pip upgraded, setuptools wheel upgraded, XCode and command line tools installed.

Trying to run (sudo) pip3 install opencv-contrib-python==4.5.3.56 fails:

copying _skbuild/macosx-10.14-x86_64-3.7/cmake-install/share/opencv4/haarcascades/haarcascade_russian_plate_number.xml -> _skbuild/macosx-10.14-x86_64-3.7/cmake-install/cv2/data/haarcascade_russian_plate_number.xml
      copying _skbuild/macosx-10.14-x86_64-3.7/cmake-install/share/opencv4/haarcascades/haarcascade_smile.xml -> _skbuild/macosx-10.14-x86_64-3.7/cmake-install/cv2/data/haarcascade_smile.xml
      copying _skbuild/macosx-10.14-x86_64-3.7/cmake-install/share/opencv4/haarcascades/haarcascade_upperbody.xml -> _skbuild/macosx-10.14-x86_64-3.7/cmake-install/cv2/data/haarcascade_upperbody.xml
      Copying files from non-default sourcetree locations
      copying LICENSE.txt -> _skbuild/macosx-10.14-x86_64-3.7/cmake-install/cv2/LICENSE.txt
      copying LICENSE-3RD-PARTY.txt -> _skbuild/macosx-10.14-x86_64-3.7/cmake-install/cv2/LICENSE-3RD-PARTY.txt
      Traceback (most recent call last):
        File "/Users/exhibition/Documents/venv_test_4/venv4/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/Users/exhibition/Documents/venv_test_4/venv4/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/exhibition/Documents/venv_test_4/venv4/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 262, in build_wheel
          metadata_directory)
        File "/private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-build-env-_g912da_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 245, in build_wheel
          wheel_directory, config_settings)
        File "/private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-build-env-_g912da_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 229, in _build_with_temp_dir
          self.run_setup()
        File "/private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-build-env-_g912da_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 282, in run_setup
          self).run_setup(setup_script=setup_script)
        File "/private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-build-env-_g912da_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 174, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 462, in <module>
          main()
        File "setup.py", line 262, in main
          cmake_source_dir=cmake_source_dir,
        File "/private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-build-env-_g912da_/overlay/lib/python3.7/site-packages/skbuild/setuptools_wrap.py", line 686, in setup
          skbuild_kw["cmake_install_dir"],
        File "setup.py", line 413, in _classify_installed_files_override
          cmake_install_dir=cmake_install_reldir,
      TypeError: _classify_installed_files() got an unexpected keyword argument 'cmake_install_dir'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for opencv-contrib-python
Failed to build opencv-contrib-python

Trying to run new version (sudo) pip3 install opencv-contrib-python fails:

Traceback (most recent call last):
      
      An error occurred while building with CMake.
        Command:
          cmake --build . --target install --config Release --
        Install target:
          install
        Source directory:
          /private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-install-6kfw2s0l/opencv-contrib-python_1cdac7916ab34fb98d01dacc90a69e53
        Working directory:
          /private/var/folders/42/tzk3gt4548d4s2znyqlsx_qm0000gn/T/pip-install-6kfw2s0l/opencv-contrib-python_1cdac7916ab34fb98d01dacc90a69e53/_skbuild/macosx-10.14-x86_64-3.7/cmake-build
      Please check the install target is valid and see CMake's output for more information.
      [end of output]

Based on issue #648 my first failed attempt is due to skbuild update, has anyone got past this? I'd want the older opencv version ideally but not a must. https://github.com/opencv/opencv-python/issues/648

Many thanks for any help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source