首页 > 解决方案 > macOS:PyQt5 与 opencv-python 冲突

问题描述

我写了一个程序,使用 pyqt5 和 opencv-python 从摄像头捕获视频,但是当我运行该程序时,我得到:

objc[35814]: Class QCocoaPageLayoutDelegate is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c5c0) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x11576c468). One of the two will be used. Which one is undefined.
objc[35814]: Class QCocoaPrintPanelDelegate is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c638) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x11576c4e0). One of the two will be used. Which one is undefined.
objc[35814]: Class QCocoaApplicationDelegate is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c340) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x117b03b88). One of the two will be used. Which one is undefined.
objc[35814]: Class QNSApplication is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c2f0) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x117b03bd8). One of the two will be used. Which one is undefined.
objc[35814]: Class QCocoaMenuLoader is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c2a0) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x117b03d18). One of the two will be used. Which one is undefined.
objc[35814]: Class QNSImageView is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c660) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x117b03e08). One of the two will be used. Which one is undefined.
objc[35814]: Class QNSStatusItem is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c6b0) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x117b03e58). One of the two will be used. Which one is undefined.
objc[35814]: Class QNSOpenSavePanelDelegate is implemented in both /Users/username/python_env/py3env/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x11439c480) and /Users/username/python_env/py3env/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x117b03ef8). One of the two will be used. Which one is undefined.

cv2 和 pyqt5 冲突。

操作系统为macOS High Sieera,python版本为3.5.2,用venv创建虚拟环境,在其中执行“pip install pyqt5”、“pip install opencv-python”,安装库。

在 ubuntu 和 windows 下它可以正常工作,没有错误,但只有 mac 不工作。

如何解决错误?

标签: pythonmacosopencvpyqt5opencv-python

解决方案


我的代码也有同样的问题。这是因为opencv和pyqt5的冲突。我能够通过安装 opencv 的无头版本来解决这个问题


推荐阅读