pyinstaller函数说明(中英文对照)

简介: pyinstaller函数说明(中英文对照)

usage: pyinstaller [-h] [-v] [-D] [-F] [–specpath DIR] [-n NAME]

[–add-data <SRC;DEST or SRC:DEST>]

[–add-binary <SRC;DEST or SRC:DEST>] [-p DIR]

[–hidden-import MODULENAME]

[–additional-hooks-dir HOOKSPATH]

[–runtime-hook RUNTIME_HOOKS] [–exclude-module EXCLUDES]

[–key KEY] [-d {all,imports,bootloader,noarchive}] [-s]

[–noupx] [–upx-exclude FILE] [-c] [-w]

[-i <FILE.ico or FILE.exe,ID or FILE.icns or “NONE”>]

[–version-file FILE] [-m ] [-r RESOURCE]

[–uac-admin] [–uac-uiaccess] [–win-private-assemblies]

[–win-no-prefer-redirects]

[–osx-bundle-identifier BUNDLE_IDENTIFIER]

[–runtime-tmpdir PATH] [–bootloader-ignore-signals]

[–distpath DIR] [–workpath WORKPATH] [-y]

[–upx-dir UPX_DIR] [-a] [–clean] [–log-level LEVEL]

scriptname [scriptname …]


positional arguments:

scriptname name of scriptfiles to be processed or exactly one

.spec-file. If a .spec-file is specified, most options

are unnecessary and are ignored.


optional arguments:

-h, --help show this help message and exit

-v, --version Show program version info and exit.

–distpath DIR Where to put the bundled app (default: ./dist)

–workpath WORKPATH Where to put all the temporary work files, .log, .pyz

and etc. (default: ./build)

-y, --noconfirm Replace output directory (default:

SPECPATH/dist/SPECNAME) without asking for

confirmation

–upx-dir UPX_DIR Path to UPX utility (default: search the execution

path)

-a, --ascii Do not include unicode encoding support (default:

included if available)

–clean Clean PyInstaller cache and remove temporary files

before building.

–log-level LEVEL Amount of detail in build-time console messages. LEVEL

may be one of TRACE, DEBUG, INFO, WARN, ERROR,

CRITICAL (default: INFO).


What to generate:

-D, --onedir Create a one-folder bundle containing an executable

(default)

-F, --onefile Create a one-file bundled executable.

–specpath DIR Folder to store the generated spec file (default:

current directory)

-n NAME, --name NAME Name to assign to the bundled app and spec file

(default: first script’s basename)


What to bundle, where to search:

–add-data <SRC;DEST or SRC:DEST>

Additional non-binary files or folders to be added to

the executable. The path separator is platform

specific, os.pathsep (which is ; on Windows

and : on most unix systems) is used. This option

can be used multiple times.

–add-binary <SRC;DEST or SRC:DEST>

Additional binary files to be added to the executable.

See the --add-data option for more details. This

option can be used multiple times.

-p DIR, --paths DIR A path to search for imports (like using PYTHONPATH).

Multiple paths are allowed, separated by ‘:’, or use

this option multiple times

–hidden-import MODULENAME, --hiddenimport MODULENAME

Name an import not visible in the code of the

script(s). This option can be used multiple times.

–additional-hooks-dir HOOKSPATH

An additional path to search for hooks. This option

can be used multiple times.

–runtime-hook RUNTIME_HOOKS

Path to a custom runtime hook file. A runtime hook is

code that is bundled with the executable and is

executed before any other code or module to set up

special features of the runtime environment. This

option can be used multiple times.

–exclude-module EXCLUDES

Optional module or package (the Python name, not the

path name) that will be ignored (as though it was not

found). This option can be used multiple times.

–key KEY The key used to encrypt Python bytecode.


How to generate:

-d {all,imports,bootloader,noarchive}, --debug {all,imports,bootloader,noarchive}

Provide assistance with debugging a frozen

application. This argument may be provided multiple

times to select several of the following options.


                    - all: All three of the following options.
                    - imports: specify the -v option to the underlying
                      Python interpreter, causing it to print a message
                      each time a module is initialized, showing the
                      place (filename or built-in module) from which it
                      is loaded. See
                      https://docs.python.org/3/using/cmdline.html#id4.
                    - bootloader: tell the bootloader to issue progress
                      messages while initializing and starting the
                      bundled app. Used to diagnose problems with
                      missing imports.
                    - noarchive: instead of storing all frozen Python
                      source files as an archive inside the resulting
                      executable, store them as files in the resulting
                      output directory.


-s, --strip Apply a symbol-table strip to the executable and

shared libs (not recommended for Windows)

–noupx Do not use UPX even if it is available (works

differently between Windows and *nix)

–upx-exclude FILE Prevent a binary from being compressed when using upx.

This is typically used if upx corrupts certain

binaries during compression. FILE is the filename of

the binary without path. This option can be used

multiple times.


Windows and Mac OS X specific options:

-c, --console, --nowindowed

Open a console window for standard i/o (default). On

Windows this option will have no effect if the first

script is a ‘.pyw’ file.

-w, --windowed, --noconsole

Windows and Mac OS X: do not provide a console window

for standard i/o. On Mac OS X this also triggers

building an OS X .app bundle. On Windows this option

will be set if the first script is a ‘.pyw’ file. This

option is ignored in *NIX systems.

-i <FILE.ico or FILE.exe,ID or FILE.icns or “NONE”>, --icon <FILE.ico or FILE.exe,ID or FILE.icns or “NONE”>

FILE.ico: apply that icon to a Windows executable.

FILE.exe,ID, extract the icon with ID from an exe.

FILE.icns: apply the icon to the .app bundle on Mac OS

X. Use “NONE” to not apply any icon, thereby making

the OS to show some default (default: apply

PyInstaller’s icon)


Windows specific options:

–version-file FILE add a version resource from FILE to the exe

-m , --manifest

add manifest FILE or XML to the exe

-r RESOURCE, --resource RESOURCE

Add or update a resource to a Windows executable. The

RESOURCE is one to four items,

FILE[,TYPE[,NAME[,LANGUAGE]]]. FILE can be a data file

or an exe/dll. For data files, at least TYPE and NAME

must be specified. LANGUAGE defaults to 0 or may be

specified as wildcard * to update all resources of the

given TYPE and NAME. For exe/dll files, all resources

from FILE will be added/updated to the final

executable if TYPE, NAME and LANGUAGE are omitted or

specified as wildcard *.This option can be used

multiple times.

–uac-admin Using this option creates a Manifest which will

request elevation upon application restart.

–uac-uiaccess Using this option allows an elevated application to

work with Remote Desktop.


Windows Side-by-side Assembly searching options (advanced):

–win-private-assemblies

Any Shared Assemblies bundled into the application

will be changed into Private Assemblies. This means

the exact versions of these assemblies will always be

used, and any newer versions installed on user

machines at the system level will be ignored.

–win-no-prefer-redirects

While searching for Shared or Private Assemblies to

bundle into the application, PyInstaller will prefer

not to follow policies that redirect to newer

versions, and will try to bundle the exact versions of

the assembly.


Mac OS X specific options:

–osx-bundle-identifier BUNDLE_IDENTIFIER

Mac OS X .app bundle identifier is used as the default

unique program name for code signing purposes. The

usual form is a hierarchical name in reverse DNS

notation. For example:

com.mycompany.department.appname (default: first

script’s basename)


Rarely used special options:

–runtime-tmpdir PATH

Where to extract libraries and support files in

onefile-mode. If this option is given, the

bootloader will ignore any temp-folder location

defined by the run-time OS. The _MEIxxxxxx-folder

will be created here. Please use this option only if

you know what you are doing.

–bootloader-ignore-signals

Tell the bootloader to ignore signals rather than

forwarding them to the child process. Useful in

situations where e.g. a supervisor process signals

both the bootloader and child (e.g. via a process

group) to avoid signalling the child twice.

(base) suncheng@canlandeMacBook-Pro ~ %


翻译版


用法:pyinstaller [-h] [-v] [-D] [-F] [–specpath DIR] [-n NAME]

[–add-data <SRC; DEST或SRC:DEST>]

[–add-binary <SRC; DEST或SRC:DEST>] [-p DIR]

[–hidden-import MODULENAME]

[–add-hooks-dir HOOKSPATH]

[–runtime-hook RUNTIME_HOOKS] [–exclude-module EXCLUDES]

[–key KEY] [-d {all,imports,bootloader,noarchive}] [-s]

[–noupx] [–upx排除文件] [-c] [-w]

[-i <FILE.ico或FILE.exe,ID或FILE.icns或“ NONE“>”

[-版本文件FILE] [-m <文件或XML>] [-r资源]

[–uac-admin] [–uac-uiaccess] [–win-private-assemblys]

[–win-prefer-redirects]

[–osx-bundle-identifier BUNDLE_IDENTIFIER]

[–runtime-tmpdir PATH] [–bootloader-ignore-signals]

[–distpath DIR] [–workpath WORKPATH] [-y]

[–upx-dir UPX_DIR] [-a] [–clean] [–log-level LEVEL]

脚本名称[脚本名称…]


位置参数:


scriptname要处理的脚本文件的名称,或者恰好是一个

.spec文件。如果指定了.spec文件,则大多数选项

是不必要的,将被忽略。


可选参数:


-h,–help显示此帮助消息并退出

-v,–version显示程序版本信息并退出。

–distpath DIR放置捆绑的应用程序的位置(默认值:./ dist)

–workpath WORKPATH将所有临时工作文件,.log,.pyz放在哪里

等(默认值:./ build)

-y,–noconfirm替换输出目录(默认值:

SPECPATH / dist / SPECNAME)而不要求

确认

–upx-dir UPX_DIR UPX实用程序的路径(默认值:搜索执行)

路径)

-a,-ascii不包括unicode编码支持(默认值:

包括(如果有)

–clean清理PyInstaller缓存并删除临时文件

在建造之前。

–log-level LEVEL生成时控制台消息中的详细信息量。水平

可能是TRACE,DEBUG,INFO,WARN,ERROR,

严重(默认:INFO)。


产生什么:


-D,–onedir创建一个包含可执行文件的单文件夹捆绑包

(默认)

-F,–onefile创建一个文件捆绑的可执行文件。

–specpath DIR文件夹,用于存储生成的规范文件(默认值:

当前目录)

-n NAME,–name NAME分配给捆绑的应用程序和规范文件的名称

(默认值:第一个脚本的基本名称)


捆绑内容,搜索位置:


–add-data <SRC; DEST或SRC:DEST>

要添加到的其他非二进制文件或文件夹

可执行文件。路径分隔符是平台

特定的os.pathsep(在Windows上是;

和:在大多数Unix系统上)。这个选项

可以多次使用。


–add-binary <SRC; DEST或SRC:DEST>

要添加到可执行文件的其他二进制文件。

有关更多详细信息,请参见–add-data选项。这个

该选项可以多次使用。

-p DIR,–paths DIR搜索导入的路径(例如使用PYTHONPATH)。

允许使用多个路径,以“:”分隔或使用

此选项多次


–hidden-import MODULENAME,-hiddenimport MODULENAME

命名在代码中不可见的导入

脚本。此选项可以多次使用。

–additional-hooks-dir HOOKSPATH

搜索钩子的其他路径。这个选项

可以多次使用。


–runtime-hook RUNTIME_HOOKS

定制运行时挂钩文件的路径。运行时挂钩是

与可执行文件捆绑在一起的代码是

在设置任何其他代码或模块之前执行

运行时环境的特殊功能。这个

该选项可以多次使用。

–exclude-module排除

可选模块或软件包(Python名称,而不是

路径名称)将被忽略(好像不是)

找到)。此选项可以多次使用。

–key KEY用于加密Python字节码的密钥。


如何产生:

-d {all,imports,bootloader,noarchive},–debug {all,imports,bootloader,noarchive}

提供调试冻结的协助

应用。可以提供此论点


相关文章
|
监控 网络协议 Ubuntu
Linux网络监控工具 - iftop
Linux网络监控工具 - iftop
352 1
|
Linux 网络安全 开发工具
校外网络连接校园网内的linux服务器方法(使用frp实现内网穿透)
平常在校园里连接校内实验室的linux服务器可以直接使用ssh直接链接私有ip地址,一旦本地移动到了校园网外部(如:使用手机流量wifi,或着暑假回家使用家庭wifi)便无法在使用ssh连接校内的服务器。本文提供一个实现校外也能访问校内服务器的方法
5927 0
校外网络连接校园网内的linux服务器方法(使用frp实现内网穿透)
|
5月前
|
人工智能 IDE 开发工具
JetBrains PyCharm 2025.1 发布 - 面向专业开发者的 Python IDE
JetBrains PyCharm 2025.1 (macOS, Linux, Windows) - 面向专业开发者的 Python IDE
567 29
JetBrains PyCharm 2025.1 发布 - 面向专业开发者的 Python IDE
|
11月前
|
安全 数据库 C++
Python Web框架比较:Django vs Flask vs Pyramid
【10月更文挑战第6天】本文比较了Python中三个最受欢迎的Web框架:Django、Flask和Pyramid。Django功能全面,适合快速开发;Flask灵活轻量,易于上手;Pyramid介于两者之间,兼顾灵活性和可扩展性。文章分析了各框架的优缺点,帮助开发者根据项目需求和个人偏好做出合适的选择。
248 4
|
Linux 开发工具 开发者
Pygame是一个免费且开源的Python库
【6月更文挑战第12天】Pygame是一个免费且开源的Python库
432 3
|
11月前
|
数据安全/隐私保护 Python
python学习十一:python常用模块使用,如 加密模块pyarmor,时间模块time等
这篇文章介绍了Python中两个常用模块的使用:加密模块pyarmor用于保护代码,以及时间模块time用于处理时间相关的功能。
477 0
|
数据处理 UED Python
Python 进度条:告别枯燥等待,让你的程序动感十足!
Python 进度条:告别枯燥等待,让你的程序动感十足!
460 1
|
Linux Windows
Installing, this may take a few minutes...WslRegisterDistribution failed with error: 0x80370114Err
Installing, this may take a few minutes...WslRegisterDistribution failed with error: 0x80370114Err
2981 3
|
负载均衡 安全 网络安全
|
数据采集 Java 开发工具
一文2500字从0到1教你搭建Android自动化python+appium环境
一文2500字从0到1教你搭建Android自动化python+appium环境
一文2500字从0到1教你搭建Android自动化python+appium环境

热门文章

最新文章