美文网首页
Python cv2.imshow() crashes with

Python cv2.imshow() crashes with

作者: 苦练 | 来源:发表于2020-03-12 13:42 被阅读0次

代码:

import cv2

img1 = cv2.imread('test.jpg')
cv2.imshow('img', img1)
cv2.waitKey(0)
cv2.destroyAllWindows()

报错如下:

objc[73658]: Class RunLoopModeTracker is implemented in both */anaconda3/lib/python3.7/site-packages/cv2/.dylibs/QtCore (0x110aca7f0) and */anaconda3/lib/libQt5Core.5.9.7.dylib (0x128e18a80). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7f80b2434fa0) is not the object's thread (0x7f80b244ec40).
Cannot move to target thread (0x7f80b2434fa0)

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

Abort trap: 6

错误的原因在于opencv中有pyQt,而另外又装了PyQt5,二者不知道使用哪一个,造成冲突。
解决方案:卸载opencv,安装opencv-python-headless

pip uninstall opencv-python or opencv-contrib-python
pip install opencv-python-headless

相关文章

网友评论

      本文标题:Python cv2.imshow() crashes with

      本文链接:https://www.haomeiwen.com/subject/fdyujhtx.html