尝试使用以下内容构建specs.spec
文件,以便在可执行文件中包含一个JSON文件。在
block_cipher = None
added_files = [
( 'configREs.json', '.'), # Loads the '' file from
# your root folder and outputs it with
# the same name on the same place.
]
a = Analysis(['gui.pyw'],
pathex=['D:\\OneDrive\\Programming\\Python Projects\\Python'],
binaries=[],
datas=added_files,
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,
exclude_binaries=True,
name='name here',
debug=False,
strip=False,
upx=True,
console=False, icon='iconname.ico', version='version.rc' )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='gui')
就像Clint在add json file with pysintaller中推荐的一样
但不起作用。
pyi-makespec specs.py
中构建spec文件pyinstaller.exe --onefile --windowed --icon=logo1.ico script.py
当您添加带有^{} 标志的文件时,在运行时,该文件将被解压到一个临时目录中,如
C:/User/Appdata/local/temp/_MEI41482
。因此,您需要从这个目录加载文件。在您可以使用^{} 获取当前临时目录并从中加载文件。在
然后生成可执行文件:
^{pr2}$相关问题 更多 >
编程相关推荐