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
BashDas
V2EX  ›  Python

求教一个 Python pyinstaller 的问题。。。

  •  
  •   BashDas · 2022-05-05 19:34:26 +08:00 · 2420 次点击
    这是一个创建于 730 天前的主题,其中的信息可能已经有所发展或是发生改变。
    python ver:3.10
    安装有:pyside6

    pyinstaller 的 spec 文件为:
    [code]
    # -*- mode: python ; coding: utf-8 -*-


    block_cipher = None


    a = Analysis(
    ['run_delivery.py'],
    pathex=['D:\\Soft\\Python3\\Lib'],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
    )
    pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

    exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='run_delivery',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    version='src\\file_version_info.txt',
    icon='src\\AppICO.ico',
    )
    [/code]

    在 Windows11 下打包为单文件(文件夹也尝试过),然后去 Windows 8.1 / Windows server 2012 R2 上运行,报错为:
    [img]https://s3.bmp.ovh/imgs/2022/05/05/0aaf9a798789f461.png[/img]

    我尝试将 plugins 目录 copy 到运行目录,貌似没啥用,包括增加系统 path 也没啥用。

    求教诸位大神,如何解决这个问题呢?。。。
    10 条回复    2022-05-07 22:58:50 +08:00
    BashDas
        1
    BashDas  
    OP
       2022-05-05 19:50:09 +08:00
    哪位大神熟悉的,麻烦支个招吧。
    coderluan
        2
    coderluan  
       2022-05-05 20:03:32 +08:00
    插件你得用 qt 带的 windeployqt 工具进行复制,自己复制可能会拉下一些资源文件的。

    https://doc.qt.io/qtforpython/deployment-pyinstaller.html
    debuggerx
        3
    debuggerx  
       2022-05-05 20:04:12 +08:00
    可以试试在你的 Windows 8.1 / Windows server 2012 R2 上打包,然后尝试在 Windows11 下运行……
    ysc3839
        4
    ysc3839  
       2022-05-05 20:07:44 +08:00 via Android
    需要具体错误才能知道是什么问题,看看有没有 debug mode 之类的选项,让它显示具体错误信息
    BashDas
        5
    BashDas  
    OP
       2022-05-05 20:21:22 +08:00
    @coderluan 好的,我试试。
    BashDas
        6
    BashDas  
    OP
       2022-05-05 20:21:38 +08:00
    @debuggerx 没用的,我试过。
    louiswong2099
        7
    louiswong2099  
       2022-05-05 23:02:53 +08:00
    建议使用 nuitka ,能避免很多问题,也支持很多插件。例如 pyqt5 等等,编译成单一文件或者文件夹发布
    louiswong2099
        8
    louiswong2099  
       2022-05-05 23:05:40 +08:00
    @BashDas
    一条命令,全部搞定所有打包,运行库,各种奇怪的依赖都给你自动化
    nuitka.bat --onefile --windows-disable-console --standalone --mingw64 --follow-imports --plugin-enable=qt-plugins main.py
    BashDas
        9
    BashDas  
    OP
       2022-05-06 22:44:43 +08:00
    @louiswong2099 尝试过,因为我是 pyside6 ,打包出来后,没有任何反应。
    BashDas
        10
    BashDas  
    OP
       2022-05-07 22:58:50 +08:00 via Android
    尝试了 3.9 和 pyqt5 ,pyinstaller 就没问题了,应该是 pyqt6 不支持 win10 以下的系统吧。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2288 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:58 · PVG 12:58 · LAX 21:58 · JFK 00:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.