首页 > 编程语言 >python 代码打包成可执行文件 pyinstaller

python 代码打包成可执行文件 pyinstaller

时间:2022-11-10 14:24:00浏览次数:52  
标签:可执行文件 None False python xxx cipher pyinstaller True

1.打包为一个目录

  pyinstaller -D xxx.py

2.打包为一个文件

  pyinstaller -F xxx.py

打包过程中会生成一个xxx.spec文件,如果有自定义的引用,可以修改这个文件,然后执行

  pyinstaller xxx.spec

xxx.spec 文件结构如下:

# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
    ['mainx.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,
    [],
    exclude_binaries=True,
    name='mainx',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='mainx',
)

 

标签:可执行文件,None,False,python,xxx,cipher,pyinstaller,True
From: https://www.cnblogs.com/nanfei/p/16876861.html

相关文章