我不确定您是否仍然需要帮助,但这应该对未来从谷歌来到这里的人有所帮助。使用首次在 py 脚本上运行 pyinstaller 时创建的规范文件。从那里您可以添加 json 和其他数据文件,如下所示
# -*- mode: python -*-
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')