- 1 报错信息
- 2 错误原因
- 3 解决方法
error 如下:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in ".../lib/python3.8/site-packages/cv2/qt/plugins" 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.2 错误原因
opencv-python 与 pyqt 的 GUI 库产生冲突
3 解决方法当使用除 OpenCV 之外的软件包创建 GUI 时,应该选择安装 opencv-python-headless 或者 opencv-contrib-python-headless(但是这样就无法使用 cv2.imshow() 等方法了)
两个包的区别:
- opencv-python: Main modules package
- opencv-contrib-python: Full package (contains both main modules and contrib/extra modules)
headless 即不依赖 GUI 库。
PyPi 官方文档解释
- 卸载当前的 opencv-python
pip uninstall opencv-python
- 重新安装无 GUI 库的 opencv-python
pip install opencv-python-headless



