欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Qt错误:This application failed to start because it could not find or load the Qt platform plugin cocoa

程序员文章站 2022-03-31 09:39:14
...

前言

运行程序报错:

objc[18135]: Class QMacAutoReleasePoolTracker is implemented in both /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (0x119b8f060) and /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x125015700). One of the two will be used. Which one is undefined.
objc[18135]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (0x119b8f0d8) and /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x125015778). One of the two will be used. Which one is undefined.
objc[18135]: Class KeyValueObserver is implemented in both /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (0x119b8f100) and /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x1250157a0). One of the two will be used. Which one is undefined.
objc[18135]: Class RunLoopModeTracker is implemented in both /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (0x119b8f150) and /Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x1250157f0). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7ff7d20164a0) is not the object’s thread (0x7ff7d37f8490).
Cannot move to target thread (0x7ff7d20164a0)
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.
qt.qpa.plugin: Could not load the Qt platform plugin “cocoa” in “/Users/zheyima/anaconda3/envs/IR_camera/lib/python3.6/site-packages/cv2/qt/plugins” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: cocoa, minimal, offscreen, webgl.

主要原因是qt冲突了,程序不知道跑哪一个。

解决方案

要么是指定一个,而我这边因为是直接用的anaconda管理,选择了最简单粗暴的方式:
先卸载有GUI版本的opencv,再安装无GUI版本的

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

重新装载一下环境,大功告成。

参考链接

  1. https://*.com/questions/25188153/this-application-failed-to-start-because-it-could-not-find-or-load-the-qt-platfo
相关标签: python