10

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)

3
  • 1
    what is the errer returned ?? ... Commented Nov 14, 2020 at 23:42
  • There is no error returning, the launcher just doesn't display a thing and the program executions gets stuck Commented Nov 15, 2020 at 1:08
  • 1
    I'm experiencing exactly the same. Tried Python 3.8 & 3.9, OpenCV 4.4 & 4.5 Tried in Pycharm & VS Code. I'm also on OSX Big Sur 11.0.1. From the moment you call imread, the process just hangs. Commented Nov 18, 2020 at 7:49

9 Answers 9

10

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.
Sign up to request clarification or add additional context in comments.

2 Comments

pip install opencv-python opencv-python-headless worked for me but sounds like against best practices :(. see here - "[...]you should SELECT ONLY ONE OF THEM. Do not install multiple different packages in the same environment. There is no plugin architecture: all the packages use the same namespace (cv2). [...]"
I also set the full access permission of file system for the Python compiler, I am not sure wether or not the missing step
4

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

pip install opencv-python-headless

Comments

3

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.

Comments

2

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

Comments

2

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

Comments

0

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

Comments

0
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.

Comments

0

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

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

1 Comment

whether you have installed opencv-contrib-python, then the opencv window cannot show.
0

This is the snap of the error that I face (Click this link to watch)

This is common problem in Mac, not only in the Big Sur but also in the Catalina and others too. and I solved this using a single command.

pip install opencv-python-head

And here watch the problem is solved now (Click this link to watch)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.