我使用的是 python 3.5 和 pyinstaller 版本 3.1.1。我指定了一个名为 SCADAsync_spec.spec 的 .spec 文件,如下所示:
block_cipher = None
a = Analysis(['SCADAsync.py'],
pathex=['C:\\repo\\analysis\\trunk\\source\\python\\functions', 'C:\\repo\\analysis\\trunk\\source\\python\\Executables'],
binaries=None,
datas=[('figs\\ROMO_icon.ico','figs'),('figs\\OpenFile2.gif','figs'),('figs\\ROMOWind_Logo2015_CMYK.png','figs')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='SCADAsync',
debug=True,
strip=False,
upx=True,
console=True
)
用
执行时效果很好pyinstaller SCADAsync_spec.spec
现在创建了两个大文件夹(dist 和 build),我更愿意将它们存储在其他地方而不是默认目录中。有谁知道如何在规范文件中设置这些文件夹的位置?我想让我的命令行命令尽可能简单,即 .exe 应该只需键入
pyinstaller SCADAsync_spec.spec
从 Pyinstaller 手册看来,我可以为规范文件 (https://pythonhosted.org/PyInstaller/spec-files.html) 指定名为“DISTPATH”和“workpath”的全局变量。但我真的不知道该怎么做。
如有任何帮助,我们将不胜感激!
尼克
最佳答案
Pyinstaller spec/build/dist 位置路径可以配置为 pyinstaller 命令的一部分。引用下面的例子
pyinstaller --specpath /opt/bk/spec --distpath /opt/bk/dist --workpath /opt/bk/build testscript.py
关于Python:如何在 Pyinstaller .spec 文件中指定输出文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37319911/