macOS:PyQt5与opencv-python冲突

3
我编写了一个使用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 Sierra,Python的版本是3.5.2,在venv中创建了一个虚拟环境,并在其中执行了"pip install pyqt5"、"pip install opencv-python"命令,安装了这两个库。

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

我应该如何解决这个错误?


你可以展示一小段代码来更好地理解吗? - Jimit Vaghela
2个回答

1
我曾遇到过类似的编程问题。这是由于 opencv 和 pyqt5 的冲突导致的。我通过安装一个无头版本的 opencv 来解决了这个问题。

0

我曾经遇到过同样的问题,并找到了两个解决方案

1、选择低版本的opencv-python(我选择了opencv-python 4.1.2.30来解决这个问题)

2、选择opencv-python-headless


1
你的回答可以通过提供更多支持信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的答案是正确的。您可以在帮助中心中找到有关如何编写良好答案的更多信息。 - Community

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接