主要参考了 https://blog.csdn.net/Jayden_Gu/article/details/94134409
还要参考 https://cloud.tencent.com/developer/news/397399
下面是我使用的参考spec
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['playGame.py'],
pathex=['D:\\software\\Play-FlappyBird-with-AI-tf2keras'],
binaries=[],
datas=[
('D:/software/Play-FlappyBird-with-AI-tf2keras/assets', 'assets'),
('D:/software/Play-FlappyBird-with-AI-tf2keras/model', 'model'),
('E:/Users/qinghua.zhu/Miniconda3/Lib/site-packages/tensorflow', 'tensorflow'),
],
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,
a.binaries,
a.zipfiles,
a.datas,
[],
name='playGame',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False )
注意,最后一行是把终端关闭,这样运行的时候就不会弹出一个黑色命令框了
打包命令
pyinstaller -F playGame.spec