user14994809
user14994809

Reputation:

Python: My MacBook suddenly fails to perform an cv2.imshow

My code worked well until morning, but suddenly cv.imshow doesn't work. (no error!!)

I didn't change the code.

I just updated my Macbook to big sur 11.1 and deleted the Paralls and the Office.

this is my code:

img = cv2.imread("test.jpg")
cv2.imshow("test", img)
cv2.waitKey()
cv2.destroyAllWindows()

I am using opencv 4.4.0

please help me..

Upvotes: 0

Views: 907

Answers (4)

Imsv
Imsv

Reputation: 1

I had the same problem with MacOS Monterey. I was able to solve it by switching from venv running python 3.9.2 to 3.10.2 release.

Upvotes: 0

rayryeng
rayryeng

Reputation: 104545

This is a common problem when upgrading to Big Sur. The solution is to uninstall OpenCV and reinstall it so that the binaries are built for Big Sur. Simply doing pip uninstall opencv-python or pip uninstall opencv-contrib-python depending on what flavour you're using for OpenCV followed by a fresh install by pip install opencv-python or pip install opencv-contrib-python should work.

Upvotes: 2

pakpe
pakpe

Reputation: 5489

Downgrade opencv-contrib-python to version 4.1.2.30. Downgrade opencv-python to version 4.2.0.34.

Upvotes: 1

user14994814
user14994814

Reputation:

Your problem is due to a MacBook update.

I had the same problem as you.

try this:

pip uninstall opencv-python
pip install opencv-python-headless

Upvotes: 0

Related Questions