I'm trying to install opencv on a raspberryPI 4 (RaspberryPI OS Bullseye x64, Python 9), that is part of installing all the dependencies for this tutorial but it always fails with the error below.
I tried to install all the dependencies from the requirements list one by one and replaced the opencv-python library with opencv-contrib-python which succeeded to install and was quite quick.
The opencv-python library fails to install and takes VERY long. So I have two main questions:
1 - why is this error happening and how to fix it?
2 - is fixing and installing opencv that way (some sources say that it takes 4h) really makes a difference?
-- Installing: /tmp/pip-install-e57iq6sc/opencv-python_02151bbb64874ba69626df8ef3e9b5e4/_skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/lbpcascades/lbpcascade_frontalface_improved.xml
-- Installing: /tmp/pip-install-e57iq6sc/opencv-python_02151bbb64874ba69626df8ef3e9b5e4/_skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/lbpcascades/lbpcascade_profileface.xml
-- Installing: /tmp/pip-install-e57iq6sc/opencv-python_02151bbb64874ba69626df8ef3e9b5e4/_skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/lbpcascades/lbpcascade_silverware.xml
--------------------------------------------------------------------------------
-- Trying "Ninja" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Ninja" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "Unix Makefiles" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Unix Makefiles" generator - success
--------------------------------------------------------------------------------
Configuring Project
Working directory:
/tmp/pip-install-e57iq6sc/opencv-python_02151bbb64874ba69626df8ef3e9b5e4/_skbuild/linux-aarch64-3.9/cmake-build
Command:
cmake /tmp/pip-install-e57iq6sc/opencv-python_02151bbb64874ba69626df8ef3e9b5e4/opencv -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-e57iq6sc/opencv-python_02151bbb64874ba69626df8ef3e9b5e4/_skbuild/linux-aarch64-3.9/cmake-install -DPYTHON_VERSION_STRING:STRING=3.9.2 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-4ll879y8/overlay/lib/python3.9/site-packages/skbuild/resources/cmake -DPython3_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPython3_LIBRARY:PATH=/usr/lib/aarch64-linux-gnu/libpython3.9.so -DPython3_NumPy_INCLUDE_DIRS:PATH=/tmp/pip-build-env-4ll879y8/overlay/lib/python3.9/site-packages/numpy/core/include -DPython_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPython_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPython_LIBRARY:PATH=/usr/lib/aarch64-linux-gnu/libpython3.9.so -DPython_NumPy_INCLUDE_DIRS:PATH=/tmp/pip-build-env-4ll879y8/overlay/lib/python3.9/site-packages/numpy/core/include -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPYTHON_LIBRARY:PATH=/usr/lib/aarch64-linux-gnu/libpython3.9.so -DPYTHON_NumPy_INCLUDE_DIRS:PATH=/tmp/pip-build-env-4ll879y8/overlay/lib/python3.9/site-packages/numpy/core/include -DPYTHON3_EXECUTABLE=/usr/bin/python3 -DPYTHON3_INCLUDE_DIR=/usr/include/python3.9 -DPYTHON3_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.9.so -DBUILD_opencv_python3=ON -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DOPENCV_SKIP_PYTHON_LOADER=ON -DOPENCV_PYTHON3_INSTALL_PATH=python -DINSTALL_CREATE_DISTRIB=ON -DBUILD_opencv_apps=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_DOCS=OFF -DCMAKE_BUILD_TYPE:STRING=Release
Copying files from CMake output
creating directory _skbuild/linux-aarch64-3.9/cmake-install/cv2
copying _skbuild/linux-aarch64-3.9/cmake-install/python/cv2.cpython-39-aarch64-linux-gnu.so -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/cv2.cpython-39-aarch64-linux-gnu.so
creating directory _skbuild/linux-aarch64-3.9/cmake-install/cv2/data
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_eye.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_eye.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_eye_tree_eyeglasses.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_eye_tree_eyeglasses.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_frontalcatface.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_frontalcatface.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_frontalcatface_extended.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_frontalcatface_extended.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_frontalface_alt.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_frontalface_alt.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_frontalface_alt2.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_frontalface_alt2.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_frontalface_alt_tree.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_frontalface_alt_tree.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_frontalface_default.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_frontalface_default.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_fullbody.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_fullbody.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_lefteye_2splits.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_lefteye_2splits.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_licence_plate_rus_16stages.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_licence_plate_rus_16stages.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_lowerbody.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_lowerbody.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_profileface.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_profileface.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_righteye_2splits.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_righteye_2splits.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_russian_plate_number.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_russian_plate_number.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_smile.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_smile.xml
copying _skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/haarcascades/haarcascade_upperbody.xml -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/data/haarcascade_upperbody.xml
Copying files from non-default sourcetree locations
copying LICENSE.txt -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/LICENSE.txt
copying LICENSE-3RD-PARTY.txt -> _skbuild/linux-aarch64-3.9/cmake-install/cv2/LICENSE-3RD-PARTY.txt
Traceback (most recent call last):
File "/tmp/tmpj_ba5nbz_in_process.py", line 280, in <module>
main()
File "/tmp/tmpj_ba5nbz_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/tmp/tmpj_ba5nbz_in_process.py", line 204, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/usr/local/lib/python3.9/dist-packages/setuptools/build_meta.py", line 412, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "/usr/local/lib/python3.9/dist-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
self.run_setup()
File "/usr/local/lib/python3.9/dist-packages/setuptools/build_meta.py", line 483, in run_setup
super(_BuildMetaLegacyBackend,
File "/usr/local/lib/python3.9/dist-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 452, in <module>
File "<string>", line 212, in main
File "/tmp/pip-build-env-4ll879y8/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 676, in setup
_classify_installed_files(
File "<string>", line 392, in _classify_installed_files_override
TypeError: _classify_installed_files() got an unexpected keyword argument 'cmake_install_dir'
----------------------------------------
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