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 · 45 天前 · 831 次点击
    这是一个创建于 45 天前的主题,其中的信息可能已经有所发展或是发生改变。
    请教使用 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  
       45 天前   ❤️ 1
    把 opencv 版本降到 4.3.0.36 了再打包
    opiviqo
        2
    opiviqo  
    OP
       45 天前
    @tangtang369 好的 谢谢
    1iuh
        3
    1iuh  
       45 天前   ❤️ 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
       45 天前
    @tangtang369 我根本没有安装 opencv
    opiviqo
        5
    opiviqo  
    OP
       45 天前
    @tangtang369 python 里面 有个 cv2 我先去按照您的思路 去搞一下
    opiviqo
        6
    opiviqo  
    OP
       45 天前
    @1iuh 谢谢 python 里有个 cv2 我先去按照您的思路 去搞一下
    qianxi0410
        7
    qianxi0410  
       45 天前   ❤️ 1
    `sudo apt-get install libxcb-xinerama0`
    fredsunme
        8
    fredsunme  
       45 天前   ❤️ 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   ·   我们的愿景   ·   实用小工具   ·   2814 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:07 · PVG 20:07 · LAX 05:07 · JFK 08:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.