请教使用 pyinstaller 打包的问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
opiviqo
V2EX    Python

请教使用 pyinstaller 打包的问题

  •  
  •   opiviqo 2024-03-13 09:33:07 +08:00 2027 次点击
    这是一个创建于 667 天前的主题,其中的信息可能已经有所发展或是发生改变。
    请教使用 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.

    我需要在新机器上安装开发机的环境吗?
    8 条回复    2024-03-13 15:26:50 +08:00
    tangtang369
        1
    tangtang369  
       2024-03-13 09:42:54 +08:00   1
    把 opencv 版本降到 4.3.0.36 了再打包
    opiviqo
        2
    opiviqo  
    OP
       2024-03-13 09:47:31 +08:00
    @tangtang369 好的 谢谢
    1iuh
        3
    1iuh  
       2024-03-13 09:48:39 +08:00   1
    正常来说 pyinstaller 打出来的包是可以直接运行的。
    你这个问题我 google 了一下应该是 PyQt 或者 OpenCV 的问题。
    https://stackoverflow.com/questions/70308309/how-to-fix-the-pyinstaller-xcb-plugin-issue-when-using-opencv-on-linux
    opiviqo
        4
    opiviqo  
    OP
       2024-03-13 09:50:49 +08:00
    @tangtang369 我根本没有安装 opencv
    opiviqo
        5
    opiviqo  
    OP
       2024-03-13 09:52:21 +08:00
    @tangtang369 python 里面 有个 cv2 我先去按照您的思路 去搞一下
    opiviqo
        6
    opiviqo  
    OP
       2024-03-13 09:52:45 +08:00
    @1iuh 谢谢 python 里有个 cv2 我先去按照您的思路 去搞一下
    qianxi0410
        7
    qianxi0410  
       2024-03-13 10:51:39 +08:00   1
    `sudo apt-get install libxcb-xinerama0`
    fredsunme
        8
    fredsunme  
       2024-03-13 15:26:50 +08:00   1
    直接报错代码扔给搜索引擎
    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 的什么包,搜包名看如何安装
    关于     帮助文档     自助推广系统     博客     API     FAQ     a href="/solana" class="dark" target="_self">Solana     3360 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 04:48 PVG 12:48 LAX 20:48 JFK 23:48
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86