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}

提供调试冻结的协助

应用。可以提供此论点


相关文章
|
C++ Python Perl
终于解决VScode中python/C++打印中文全是乱码的问题了
终于解决VScode中python/C++打印中文全是乱码的问题了
终于解决VScode中python/C++打印中文全是乱码的问题了
|
2月前
|
开发工具 git Python
Python小技巧:满意的逗号放置
Python小技巧:满意的逗号放置
|
2月前
|
Python
python朗读播放中文和英文
python朗读播放中文和英文
|
2月前
|
开发工具 git Python
Python 技巧:满意的逗号放置
Python 技巧:满意的逗号放置
关于QtCreator使用fcitx无法输入中文的解决方法(从根本解决问题)
关于QtCreator使用fcitx无法输入中文的解决方法(从根本解决问题)
|
6月前
|
自然语言处理 开发者 Windows
Win11环境Mecab日语分词和词性分析以及动态库DLL not found问题(Python3.10)
日语因为存在假名,会导致翻译软件进行翻译时机翻味道过重的问题,比如積ん読(つんどく)这个词,大多数软件会翻译成:堆积的读,但其实是明明买了书却不读,光放着的意思。有时候也需要单独查句子中的单词释义来理解句子的意思,但一看下去全是假名,无法像中文或者英文那样进行简单的分词操作。 本次我们基于Python3.10的三方库Mecab来对日语进行分词和词性分析。
Win11环境Mecab日语分词和词性分析以及动态库DLL not found问题(Python3.10)
|
Linux C++ iOS开发
小秘技:怎样用python来获取各种DOS命令显示的内容?注意不是返回值哦!
小秘技:怎样用python来获取各种DOS命令显示的内容?注意不是返回值哦!
141 0
|
程序员 数据安全/隐私保护 Python