1.安裝模塊
cmd或者git bash
pip install pyinstaller
pip install tinyaes
2.示例文件
a.py 為主工程文件
b.py為主工程文件依賴文件
$ cat a.py
import b
$ cat b.py
print('b.py')
3.打包 a.py 以及b.py
3.1.生成配置
pyinstaller --key xiaomage -F a.py
3.2.修改配置文件a.spec
$ cat a.spec
# -*- mode: python ; coding: utf-8 -*-
block_cipher = pyi_crypto.PyiBlockCipher(key='xiaomage')
a = Analysis(
['a.py','b.py'], #此處添加(b.py)
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
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='a',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
3.3再次生成
pyinstaller a.spec
dist 下的 a.exe 即為打包好的執(zhí)行文件