我正在尝试使用pyinstaller部署python项目。我的规格文件如下,它依赖于sklearn:
block_cipher = None
a = Analysis(['MainUserInterface.py'],
pathex=['..\\TSCExcelToolSet'],
binaries=[],
datas=[],
hiddenimports=['sklearn'],
hookspath=[],
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,
exclude_binaries=True,
a.zipfiles,
a.datas,
[],
name='MainUserInterface',
debug=False,
strip=False,
upx=False,
console=True)
当我尝试运行
pyinstaller MainUserInterface.spec
出现此错误:
SyntaxError: positional argument follows keyword argument
答案 0 :(得分:1)
您正试图传递exclude_binaries=True
,它会被翻译为位置参数,并且因为它在作为关键字参数的a.zipfiles
,a.datas
和[]
之前传递,因此将给出一个SyntaxError。因此,您需要在关键字参数之后传递它。您可以在here中找到更多信息。
block_cipher = None
a = Analysis(['MainUserInterface.py'],
pathex=['..\\TSCExcelToolSet'],
binaries=[],
datas=[],
hiddenimports=['sklearn'],
hookspath=[],
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.zipfiles,
a.datas,
[],
exclude_binaries=True,
name='MainUserInterface',
debug=False,
strip=False,
upx=False,
console=True)