option(s) not allowed: --onedir/--onefile --version-filemakespec options not valid when a .spec

D:\python\python11\Scripts>pyinstaller.exe -D --version-file D:\version\v1.0\v4.0\ClientAuto\ClientAuto\file_version_info.txt D:\version\v1.0\v4.0\ClientAuto\ClientAuto\RunMain.spec
1266 INFO: PyInstaller: 6.3.0
1266 INFO: Python: 3.11.7
1342 INFO: Platform: Windows-10-10.0.17763-SP0
option(s) not allowed:
  --onedir/--onefile
  --version-file
makespec options not valid when a .spec file is given

pyinstaller打包python程序报错
报错信息如下:

option(s) not allowed:
  --onedir/--onefile
makespec options not valid when a .spec file is given

 代码结构如下:


# -*- mode: python ; coding: utf-8 -*-
 
 
a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[('./lib', './lib')],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
)
pyz = PYZ(a.pure)
 
exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='main',
    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,
)

解决:不使用 -F 参数

pyinstaller main.spec

打包成功!!! 

option(s) not allowed: --onedir/--onefile --version-filemakespec options not valid when a .spec_第1张图片

你可能感兴趣的:(python,开发语言)