Compatibility issues between OpenCV and Torchvision

I’m having some troubles with a project on artificial vision where I need to use, among the various, OpenCV and torchvision libraries. In particular I have these versions:

Opencv-python Version: 4.10.0.84
Torchvision Version: 0.19.1
Torch Version: 2.4.1

I also tried with a simple Python script to ensure that the problem was not of my code

import torch
import torchvision
import cv2
import numpy as np

# Crete a black image
img = np.zeros((100, 100, 3), dtype=np.uint8)

# Show the image
cv2.imshow('Test Window', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

If I run this code with both torchvision and cv2, my script freezes, but if I try without torchvision no problems occur. The main problem seems also to be relative to the imshow() function.

I cannot reproduce the issue and see the expected behavior waiting for a key input and closing the window afterwards using the same versions: