请教使用 pyinstaller 打包的问题

57 天前
 opiviqo
请教使用 pyinstaller 打包的问题

Ubuntu20.04 开发机器使用如下指令:
pyinstaller --onefile main.py
打包成功且能运行
程序主要环境是 python3.10 和 pyside6 ,python3.10 采用虚拟环境

换一台同系统电脑运行上述程序失败,报错:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/tmp/_MEIve8G8s/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.

我需要在新机器上安装开发机的环境吗?
860 次点击
所在节点    Python
8 条回复
tangtang369
57 天前
把 opencv 版本降到 4.3.0.36 了再打包
opiviqo
57 天前
@tangtang369 好的 谢谢
1iuh
57 天前
正常来说 pyinstaller 打出来的包是可以直接运行的。
你这个问题我 google 了一下应该是 PyQt 或者 OpenCV 的问题。
https://stackoverflow.com/questions/70308309/how-to-fix-the-pyinstaller-xcb-plugin-issue-when-using-opencv-on-linux
opiviqo
57 天前
@tangtang369 我根本没有安装 opencv
opiviqo
57 天前
@tangtang369 python 里面 有个 cv2 我先去按照您的思路 去搞一下
opiviqo
57 天前
@1iuh 谢谢 python 里有个 cv2 我先去按照您的思路 去搞一下
qianxi0410
57 天前
`sudo apt-get install libxcb-xinerama0`
fredsunme
57 天前
直接报错代码扔给搜索引擎
https://github.com/NVlabs/instant-ngp/discussions/300
https://forum.qt.io/topic/119109/using-pyqt5-with-opencv-python-cv2-causes-error-could-not-load-qt-platform-plugin-xcb-even-though-it-was-found
#7 也说了, 大概率是缺包了
既然是两个相同系统的电脑,直接对比下环境区别
'apt list |grep xcb' 看下缺了 xcb 的什么包,搜包名看如何安装

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1023096

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX