pyinstaller打包

cooolr 于 2022-09-22 发布
pip install pyinstaller
# 打包成一个文件需要加-F参数
# 其他参数都可以加在这里
pyi-makespec --name main --onefile main.py
python -m PyInstaller main.spec
# -*- mode: python ; coding: utf-8 -*-

import os

path = os.path.abspath(".")

block_cipher = None

a = Analysis(
    ['MainServer.py'],
    pathex=[path], # 添加当前目录到搜索路径
    binaries=[],
    **datas=[
        ('flaskSystem', 'flaskSystem'),
        ('md', 'md'), # 指定相对路径
        ('WebSourceCode', 'WebSourceCode'), # 指定相对路径
    ],**
    **hiddenimports=[ # 添加可能的隐藏导入
        'flask',
        'flask_cors',
        'pycryptodome',
        'requests',
        'werkzeug',
    ],**
    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='QQFlacMusicDownloader',
    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,
)
from pymssql import _mssql
from pymssql import _pymssql
import uuid
import decimal