gpt4 book ai didi

python - PyInstaller 3.2.1 与 Kivy 1.10.0 pyz 语法错误并且不打包

转载 作者:太空宇宙 更新时间:2023-11-03 15:13:01 25 4
gpt4 key购买 nike

按照 Kivy.org 应用程序打包教程,首次在 Windows 10 上使用 PyInstaller 3.2.1 打包用 python 3.6.1 编写的 Kivy 1.10.0 应用程序时。当我在 Windows 命令行中打包 .spec 文件时,出现与 pzy 变量相关的语法错误。我查看了 Kivy 支持部分、PyInstaller 支持页面,并使用 Wheel 而不是 Pycharm 重新安装了 PyInstaller 和 Kivy。我从 Windows 命令行收到的错误消息如下:

92 INFO: PyInstaller: 3.2.1
92 INFO: Python: 3.6.1
93 INFO: Platform: Windows-10-10.0.14393-SP0
95 INFO: UPX is not available.
Traceback (most recent call last):
File "C:\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\python36\lib\site-packages\PyInstaller\__main__.py", line 97, in <module>
run()
File "C:\python36\lib\site-packages\PyInstaller\__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\python36\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\python36\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\python36\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 20
pyz = PYZ(a.pure, a.zipped_data,
^
SyntaxError: invalid syntax

我一直在使用的.spec文件如下:

# -*- mode: python -*-
from kivy.tools.packaging.pyinstaller_hooks import get_deps_minimal, get_deps_all, hookspath, runtime_hooks
from kivy.deps import sdl2, glew
block_cipher = None

a = Analysis(['KivyCalculator\\main.py'],
pathex=['C:\\Users\\lukeb\\OneDrive\\Documents\\Python\\'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=hookspath(),
runtime_hooks=runtime_hooks(),
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher
**get_deps_all()

pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='KivyCalculator',
debug=False,
strip=False,
upx=True,
console=True , icon='KivyCalculator\\icon.ico')
coll = COLLECT(exe,Tree('C:\\Users\\lukeb\\OneDrive\\Documents\\Python\\KivyCalculator'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='KivyCalculator')

我将非常感谢人们可以提供的任何帮助。

最佳答案

这是因为您在 .spec 文件中输入了一个拼写错误,而该文件只是 Python,所以您基本上会得到这样的结果:

a = Analysis(...,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher # no comma
**get_deps_all() # no closing bracket

pyz = PYZ(a.pure, a.zipped_data, # bam, syntax error
cipher=block_cipher)

关于python - PyInstaller 3.2.1 与 Kivy 1.10.0 pyz 语法错误并且不打包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44084635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com