""" PyInstaller 打包配置优化 """ import sys import os block_cipher = None # 获取项目根目录 project_root = os.path.dirname(os.path.abspath(SPEC)) a = Analysis( ['ArticleReplace.py'], pathex=[project_root], binaries=[], datas=[ ('config.ini', '.'), ('config_manager.py', '.'), ('src', 'src'), ('drivers', 'drivers'), ], hiddenimports=[ 'customtkinter', 'customtkinter.*', 'PIL', 'PIL._tkinter_finder', 'selenium', 'selenium.webdriver', 'selenium.webdriver.chrome', 'selenium.webdriver.chrome.service', 'selenium.webdriver.chrome.options', 'selenium.webdriver.support', 'selenium.webdriver.support.ui', 'selenium.webdriver.support.wait', 'selenium.webdriver.common', 'selenium.webdriver.common.by', 'bs4', 'pandas', 'openpyxl', 'requests', 'configparser', ], hookspath=[], hooksconfig={}, runtime_hooks=[], excludes=[ 'tkinter', 'matplotlib', 'numpy', 'scipy', 'pandas.plotting', 'pandas._libs.tslibs.base', ], 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='ArticleReplace', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, console=False, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, codesign_identity=None, entitlements_file=None, icon=None, ) coll = COLLECT( exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='ArticleReplace', )