python - 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 不工作。
如何解决错误?
解决方案
我的代码也有同样的问题。这是因为opencv和pyqt5的冲突。我能够通过安装 opencv 的无头版本来解决这个问题
推荐阅读
- javascript - 该命令仅在我不放 args 时才响应,但当我放它时它什么也不做
- mdx - 按度量的小计过滤
- excel - 复杂的 Excel 数据提取/转换与 Power BI 的集成
- javascript - ClearRect 正在删除画布上的所有内容
- python - 在每组最后一句话的末尾添加字符串
- c - 在循环中初始化唯一指针(用于哈希表)
- javascript - NodeJS 仅在将所有对象保存到数据库后才向客户端发送响应
- javascript - React 模板文字变量样式
- node.js - ReferenceError: 要求未定义(在我的休息 api 上)
- swift - 如何创建一组具有在 SwiftUI 中编辑的单独变量的文本字段?