【问题标题】:PyQt5 and OpenCV have similar libraries; how to avoid conflict between the 2?PyQt5 和 OpenCV 有类似的库;如何避免两者之间的冲突?
【发布时间】:2018-12-24 13:37:35
【问题描述】:

我在同一个 conda 虚拟环境中拥有 PyQt5 和 OpenCV。

opencv-python==3.4.1.15    
PyQt5==5.10.1    

每当我运行我的 PyQt5 应用程序时,都会收到许多类似这样的警告:

objc[7992]: Class QCocoaPageLayoutDelegate is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109ae0290) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x10a387f20). One of the two will be used. Which one is undefined.
objc[7992]: Class QCocoaPrintPanelDelegate is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109ae0308) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x10a387f70). One of the two will be used. Which one is undefined.    
objc[7992]: Class QCocoaApplicationDelegate is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109ae0010) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x10c6ed480). One of the two will be used. Which one is undefined.    
objc[7992]: Class QNSApplication is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109adffc0) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x10c6ed4d0). One of the two will be used. Which one is undefined.    
objc[7992]: Class QCocoaMenuLoader is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109adff70) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x10c6ed570). One of the two will be used. Which one is undefined.    
objc[7992]: Class QNSImageView is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109ae0330) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x10c6ed660). One of the two will be used. Which one is undefined.    
objc[7992]: Class QNSStatusItem is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109ae0380) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x10c6ed6b0). One of the two will be used. Which one is undefined.    
objc[7992]: Class QNSOpenSavePanelDelegate is implemented in both /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/cv2/.dylibs/QtGui (0x109ae0150) and /Users/alexryan/miniconda3/envs/qacker/lib/python3.5/site-packages/PyQt5/Qt/plugins/platforms/libqcocoa.dylib (0x10c6ed750). One of the two will be used. Which one is undefined.

处理这个问题的适当方法是什么?

【问题讨论】:

  • 我在使用 PyQt 和 opencv 的 mac 上遇到了类似的问题。你找到解决办法了吗?
  • 很遗憾,没有
  • 你们找到解决方案了吗? @PunitSoni
  • @sona 没有。该问题也已发布到 QtForum,但该论坛目前似乎已关闭:forum.qt.io/topic/93012/…
  • 我也面临同样的问题。你们找到解决办法了吗?

标签: python opencv pyqt5 conda


【解决方案1】:

就我而言,我解决了删除 opencv-python 的问题

pip3 uninstall opencv-python

然后安装opencv-headless

pip3 install opencv-python-headless

之后,我的应用程序再次运行。

【讨论】:

    【解决方案2】:

    我通过GUI卸载opencv并安装无头版本解决了这个问题:

    pip 卸载 opencv-contrib-python

    pip install opencv-contrib-python-headless

    opencv 中的 namedWindow 函数仍然有效。

    【讨论】:

    • 我刚刚复制了这个并测试了你的建议并且它有效,所以这是我的 +1。
    • 我搜索了很多关于这个问题的答案,很多答案都太复杂了。这个简单且有效。
    • 也为我解决了这个问题。非常感谢!
    猜你喜欢
    • 2019-02-21
    • 1970-01-01
    • 2014-10-09
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多