Opencv imshow crashes python launcher on macOS 11.0.1 (Big Sur)

Viewed 4374

I'm trying to run some old code from gaussian filter when I find out that python launcher gets stuck trying to do the imshow function. I tried:

  • Used Matplotlib to display a graph to see if the python launcher was the problem but no, graph showed up fine.

  • Remove process in between just to have the image read and display in fear that something in my code was breaking the launcher but no success.

  • Reinstalled opencv-python but no success.

Also saw one question like this in the google search but OP deleted it.

Has anyone encounter this issue or has any fix for this?

Example code:

import cv2 as cv
filename = 'chessboard.png'
img = cv.imread(filename)
cv.imshow('dst',img)
cv.waitKey(0)

OS: MacOS Big Sur (11.0.1)

9 Answers

I resolved the issue with below steps:

  1. Install the anaconda.
  2. Install the libraries needed.
  3. Run the script, there is an error appeared as below:

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.

  1. then I installed two libraies:

pip install opencv-python opencv-python-headless

  1. Retry run the script, the image can be shown on the left top of the monitor.

I was also facing the same problem. I solved it by just installing opencv-python-headless. use:

pip install opencv-python-headless

I also encounter this problem when I upgraded to Big Sur.

  1. Uninstall anaconda(every package), and reinstall python.

  2. pip install opencv-python opencv-python-headless

  3. This does help me with imshow() but I can't run cv.face. This attribute is not found.

  4. This solve my problem

pip install --force-reinstall opencv-contrib-python==4.1.2.30 This downgrade gets my code working again.

I naturally have my environment installed in anaconda. I had to use the package opencv-python-headless. It is now running again. Also the

cv.imread(...)

method

I also ran into this problem after installing macOS Big Sur. It was not only cv2.imshow() that did not respond but also cv2.namedWindow()

cv2.imread() was working however.

Solution was to install opencv-python-headless as others have said before

import cv2 as cv
import matplotlib.pyplot as plt
filename = 'chessboard.png'
img = cv.imread(filename)
cv.imshow('dst',img)
cv.waitKey(0)

I also found that pc hangs up at cv.imread(...). Nothing was happened. So I added line 2 import matplotlib.pyplot ..., the image was displayed.

I had the same problem as you. I solved it by installing anaconda and using anaconda's virtual environment(PyCharm)

It seems to be a package reference issue. My solution solves the issue:

  • re-create conda env
  • re-install package, incl. opencv-python-headless
Related