求教一个 Python 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
BashDas
V2EX    Python

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

  •  
  •   BashDas 2022-05-05 19:34:26 +08:00 3087 次点击
    这是一个创建于 1329 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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     Solana     991 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 24ms UTC 19:11 PVG 03:11 LAX 11:11 JFK 14:11
    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