The meaning of each parameter of PyInstaller

Description

以下介绍假设用户脚本为main.py,生成结果为main.exe。
有些参数实在很少用到,只列出简单介绍,具体请参阅原文。
原文(英文): https://pyinstaller.readthedocs.io/en/v3.3.1/usage.html

General parameters

parameter name description Description
-h Show help no
-v Show version number no
–distpath Where to put the generated files Default: in the dist folder of the current directory
–workpath Where to put the intermediate files in the generation process Default: in the build folder of the current directory
-and If the generated file already exists in the dist folder, the user is not asked and overwritten Default: Ask whether to overwrite
-Upx-dir UPX_DIR Specify the directory of the upx tool Default: execution path
-a Does not include unicode support Default: support unicode as much as possible
–clean At the beginning of this compilation, clear the various files generated by the previous compilation Default: do not clear
–log-level LEVEL Control the information printed by pyi during compilation There are a total of 6 levels, from low to high respectively TRACE DEBUG INFO (default) WARN ERROR CRITICAL. That is, TRACE and DEBUG information will not be printed under the default empty

Parameters related to the generated result

parameter name description Description
-D Program to generate one-folder (default) The generated result is a directory in which various third-party dependencies, resources and exe are stored at the same time
-F Program to generate one-file The generated result is an exe file, all third-party dependencies, resources and codes are packaged into the exe
–specpath Specify the storage path of the .spec file Default: current directory
-n The file name of the generated .exe file and .spec Default: the name of the user script, namely main.py and main.spec

Specify which resources and codes to package

parameter name description Description
–add-data Pack additional resources Usage: pyinstaller main.py --add-data=src;dest. Windows is divided by; division, linux is divided by: division
–add-binary Pack additional code Usage: same as -add-data. Unlike –add-data, for files added with binary, pyi will analyze the files it refers to and add them together
-p Specify additional import path, similar to using PYTHONPATH See PYTHONPATH
–hidden-import Pack additional py libraries During the analysis process of pyi, some imports are not correctly analyzed, and an import error will be reported during operation. This parameter can be used at this time
–additional-hooks-dir Specify the user's hook directory For hook usage, see other, system hooks are in the PyInstaller\hooks directory
–runtime-hook Specify user runtime-hook If this parameter is set, runtime-hook will be run before running main.py
–exclude-module Module to be excluded Pyi will analyze many interrelated libraries, but some libraries are useless to users. You can use this parameter to exclude these libraries, which helps reduce the size of the generated files
–key pyi will store the bytecode and specify the key of the encrypted bytecode 16-bit string

Generate parameters

parameter name description Description
-d When executing the generated main.exe, some logs of pyi will be output, which is helpful for troubleshooting Default: do not output pyi log
-s Optimize symbol table The original text clearly stated that it is not recommended to be used on windows
–noupx Mandatory not to use upx Default: Use whenever possible.

other

parameter name description Description
–runtime-tmpdir Specify the temporary directory at runtime Default: use system temporary directory

Parameters specific to Windows and Mac

parameter name description Description
-c Show command line window Contrary to -w, this parameter is included by default
-w Do not display the command line window This parameter is useful when writing GUI programs.
-i Specify an icon for main.exe pyinstaller -i beauty.ico main.py

Windows-specific parameters

parameter name description Description
–version-file Add version information file pyinstaller --version-file ver.txt
-m, --manifest Add manifest file pyinstaller -m main.manifest
-r RESOURCE Please refer to the original  
–uac-admin Please refer to the original  
–uac-uiaccess Please refer to the original

Guess you like

Origin blog.csdn.net/u012308586/article/details/108383292