Building wheel time out for opencv-contrib-python

I am supporting a student who is working on the Autonomous RVR kit. He would like to add facial recognition to the RVR and it needs opencv. However, we can’t get past the classic time out issue on:

“Building wheel for opencv-contrib-python (pyproject.toml) … -”

I have spent hours trying every possible solution including rebuilding the Pi from scratch. The following solutions have been tried.

Upgrading all packages / Updating pip / Python / Updating to Bullseye etc etc. I am running:

Raspberry Pi 4

NAME=“Raspbian GNU/Linux”

VERSION_ID=“11”

VERSION=“11 (bullseye)”

VERSION_CODENAME=bullseye

Python version: 3.9.2

Pip version: 21.3.1

Here is the command and log when I try (I have left it for many hours as I appreciate it can take time). However, it continues to get stuck at this stage. Grateful for any advice.

sudo pip3 install opencv-contrib-python

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple

Collecting opencv-contrib-python

Using cached opencv-contrib-python-4.5.4.58.tar.gz (150.7 MB)

Installing build dependencies … done

Getting requirements to build wheel … done

Preparing metadata (pyproject.toml) … done

Requirement already satisfied: numpy>=1.19.3 in /usr/lib/python3/dist-packages (from opencv-contrib-python) (1.19.5)

Building wheels for collected packages: opencv-contrib-python

Building wheel for opencv-contrib-python (pyproject.toml) … -