Cannot install Open-CV

I tried reinstalling Python, but then had another issue come up with the Pi, so I formatted the sd card and did a clean install of Pi OS 32-bit. Then went in, and only installed the libraries I needed for my project.

After a complete and total clean install, I still cannot install OpenCV-Python. This time, I tried installing via “Manage Packages” in Thonny on the Pi. It gets to the point of “Building wheel for opencv-python (PEP 517)” and this is where it fails.

I’ve copied the output/error message and posted below. In the full output, there is A LOT of “Installing: /tmp/pip-install-rg0384o8/opencv-python…”, so I just included the last 2 before the error.

  -- Installing: /tmp/pip-install-rg0384o8/opencv-python_43f9f441cce64b5aaf05bbe47f8689ce/_skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/lbpcascades/lbpcascade_profileface.xml
  -- Installing: /tmp/pip-install-rg0384o8/opencv-python_43f9f441cce64b5aaf05bbe47f8689ce/_skbuild/linux-aarch64-3.9/cmake-install/share/opencv4/lbpcascades/lbpcascade_silverware.xml
  Copying files from CMake output
  Traceback (most recent call last):
    File "/tmp/tmpep4jioz9_in_process.py", line 280, in <module>
      main()
    File "/tmp/tmpep4jioz9_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/tmp/tmpep4jioz9_in_process.py", line 204, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-ar1ozsrn/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-ar1ozsrn/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-ar1ozsrn/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 267, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-ar1ozsrn/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-ar1ozsrn/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-aarch64-3.9/cmake-install/python/cv2/config-3.py'
  ----------------------------------------
  ERROR: Failed building wheel for opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
Process returned with code 1