I am new to programming and I am stuck trying to run a very simple Python script, getting this 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.
zsh: abort python3 mypuppy1.py
The script code is:
import cv2
img = cv2.imread('00-puppy.jpg')
while True:
cv2.imshow('Puppy',img)
if cv2.waitKey(1) & 0xFF == 27:
break
cv2.destroyAllWindows()
However this Notebook code works in JupyterLab:
import cv2
img = cv2.imread('00-puppy.jpg')
cv2.imshow('Puppy', img)
cv2.waitKey()
I am on macOS, using Anaconda and JupyterLab.
I have tried googling the issue but either I couldn't implement the solutions right or they just do not work for me as most of them are for Windows' users.
I would appreciate any help with this issue. Thanks!
Note: You can install only plugins that are supported by your Qt Creator version. To install plugins: Select Help > About Plugins > Install Plugins. In the Source dialog, enter the path to the archive or library that contains the plugin.
In order to fix the “Application failed to start because no Qt platform plugin could be initialized” error, you should uninstall all recently installed applications and see if that solves your problem in normal mode.
Qt provides a simple plugin interface which makes it easy to create custom database drivers, image formats, text codecs, styles and widgets as stand-alone components. Warning: Qt 3.0. 5 introduces changes into some aspects of plugins, in particular regarding loading, path handling and library versions.
On Linux, the xcb QPA (Qt Platform Abstraction) platform plugin is used. It provides the basic functionality needed by Qt GUI and Qt Widgets to run against X11.
Try installing
pip3 install opencv-python==4.1.2.30
For Ubuntu users,
sudo apt-get install qt5-default
fixes the issue.
(I'm using OpenCV 4.4)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With