推荐学习书目
› 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 · Mar 13, 2024 · 4859 views
    This topic created in 983 days ago, the information mentioned may be changed or developed.
    请教使用 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 replies  •  2024-03-13 15:26:50 +08:00
    tangtang369
    tangtang369
    Mar 13, 2024❤️1
    1
    把 opencv 版本降到 4.3.0.36 了再打包
    opiviqo
    opiviqo
    OP
    Mar 13, 2024
    2
    @tangtang369 好的 谢谢
    1iuh
    1iuh
    Mar 13, 2024❤️1
    3
    正常来说 pyinstaller 打出来的包是可以直接运行的。
    你这个问题我 google 了一下应该是 PyQt 或者 OpenCV 的问题。
    https://stackoverflow.com/questions/70308309/how-to-fix-the-pyinstaller-xcb-plugin-issue-when-using-opencv-on-linux
    opiviqo
    opiviqo
    OP
    Mar 13, 2024
    4
    @tangtang369 我根本没有安装 opencv
    opiviqo
    opiviqo
    OP
    Mar 13, 2024
    5
    @tangtang369 python 里面 有个 cv2 我先去按照您的思路 去搞一下
    opiviqo
    opiviqo
    OP
    Mar 13, 2024
    6
    @1iuh 谢谢 python 里有个 cv2 我先去按照您的思路 去搞一下
    qianxi0410
    qianxi0410
    Mar 13, 2024❤️1
    7
    `sudo apt-get install libxcb-xinerama0`
    fredsunme
    fredsunme
    Mar 13, 2024❤️1
    8
    直接报错代码扔给搜索引擎
    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 的什么包,搜包名看如何安装
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1916 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 14:58 · PVG 22:58 · LAX 06:58 · JFK 09:58
    ♥ Do have faith in what you're doing.