opencv-python: Qt Error on cv2.imshow - Specific to version 4.2.0.32
Issue
Calling cv2.imshow
with opencv-python 4.2.0.32
results in the following error:
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Solution
I am able to fix the issue by:
- uninstalling the current version:
4.2.0.32
- reinstalling the previous version:
4.1.2.30
pip uninstall opencv-python
pip install opencv-python==4.1.2.30
Repoduce
import cv2
img = cv2.imread('./path/to/picture.png', cv2.IMREAD_GRAYSCALE)
cv2.imshow('image', img)
- macOS 10.15.2 x86
- Python 3.8.1
- opencv-python 4.2.0.32
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 17 (14 by maintainers)
try degrading opencv-contrib by something like sudo pip install opencv-contrib-python==4.0.0.21
this will help
Thanks for the clarification, I probably mixed this up with the case where another process needed to modify the environment variables (I was trying to do something like that a few years back with some other project…). Thanks for the PR, I’ll have a look at it during next week.