在 PyInstaller 中使用带有 .spec 的 --onefile [英] Using --onefile with a .spec in PyInstaller

查看:85
本文介绍了在 PyInstaller 中使用带有 .spec 的 --onefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PyInstaller 使用 .spec 文件编译"一个程序.我正在使用 .spec 文件,因为我需要在程序中包含一个额外的文件.当我尝试执行 PyInstaller --onefile Prog.spec 时,它仍然在 dist 中创建一个文件夹,其中所有文件都是分开的,而不是像我期望的那样创建一个文件.如果我执行 PyInstaller --onefile Prog.py 然后它会在 dist 中创建一个 .exe 文件,这就是我想要的.使用 .spec 文件时,我需要做什么特别的事情吗?

I'm "compiling" a program using PyInstaller using a .spec file. I'm using the .spec file because I need to include an extra file in the program. When I try to do PyInstaller --onefile Prog.spec, it still makes a folder in dist with all the files separate instead of making a single file as I'd expect. If I do PyInstaller --onefile Prog.py then it does make a single .exe file in dist, which is what I want. Is there something special I need to do when using a .spec file?

推荐答案

使用 pyi-makespec --onefile yourprogram.py 为 onefile 模式生成示例规范文件.

Use pyi-makespec --onefile yourprogram.py to generate a sample spec file for onefile mode.

https://pyinstaller.readthedocs.io/en/stable/man/pyi-makespec.html

没有COLLECT调用,EXE调用不同.示例:

There is no COLLECT call, and the EXE call is different. Example:

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='main',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )

这篇关于在 PyInstaller 中使用带有 .spec 的 --onefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆