我正在尝试使用PyInstaller将一个应用程序kivy部署到Windows,就像本教程一样:为Windows 创建一个包
但当我尝试执行时,它崩溃了。
我尝试使用--onefile
命令来创建。
这是我的树文件夹:
Detector:.
│ camera.py
│ data.json
│ dataControler.py
│ gui.kv
│ Main.py
│ controle.py
│ detector.model
│ detector.spec
│
├───face_detector
│ deploy.prototxt
│ res10_300x300_ssd_iter_140000.caffemodel
│
├───icons
│ agta.jpg
│ ico.png
│ icoagta.ico
│
└───songs
en.mp3
ptbr.mp3
我在kivy教程中解释了探测器.spec
探测器规格
# -*- mode: python ; coding: utf-8 -*-
from kivy.tools.packaging.pyinstaller_hooks import get_deps_minimal, get_deps_all, hookspath, runtime_hooks
block_cipher = None
a = Analysis(['Main.py'],
pathex=['C:\Users\**User**\Desktop\detector\Main.py'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=hookspath(),
runtime_hooks=runtime_hooks(),
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
**get_deps_all())
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
coll = COLLECT(exe, Tree('detector\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='detector')
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='detector',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True , icon='icons\icoagta.ico')
当我执行de Main.py时,它非常有效。然而当我打包时,它不起作用。
有人知道怎么解决吗?我尝试了文档,但仍然没有找到解决方案。
经过多次尝试,我的解决方案是使tensorflow==1.14的向下度与PyInstaller兼容。并将我的.spec更改为
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
from kivy_deps import sdl2, glew, gstreamer
a = Analysis(['C:\Users\bababa\Desktop\mask\Main.py'],
pathex=['C:\Users\bababa\Desktop\mask', 'C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86','C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x64'],
binaries=[],
datas=[],
hiddenimports=[],
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,
name='Mask',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True , icon='C:\Users\bababa\Desktop\mask\icons\icoagta.ico')
coll = COLLECT(exe,Tree('C:\Users\bababa\Desktop\mask'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins + gstreamer.dep_bins)],
strip=False,
upx=True,
upx_exclude=[],
name='Mask')
现在它工作良好