1 - Pyinstaller简介

Home-page: http://www.pyinstaller.org

PyInstaller是一个能够在多系统平台(Windows、*NIX、Mac OS)上将Python程序冻结(打包)为独立可执行文件的工具。

  • 可以捆绑所需的第三方库,并可与绝大多数常见的库和框架配合使用;
  • 可以与Python2.7和3.3-3.6协同工作,由于透明压缩而构建了更小的可执行文件;
  • 使用OS支持来加载动态库,从而确保完全兼容;

2 - Pyinstaller安装

$ pip3 install --proxy=10.144.1.10:8080 pyinstaller
Collecting pyinstaller
Using cached PyInstaller-3.3.1.tar.gz
Requirement already satisfied: setuptools in c:\python36\lib\site-packages (from pyinstaller)
Collecting pefile>=2017.8.1 (from pyinstaller)
Using cached pefile-2017.11.5.tar.gz
Collecting macholib>=1.8 (from pyinstaller)
Using cached macholib-1.9-py2.py3-none-any.whl
Collecting future (from pyinstaller)
Using cached future-0.16.0.tar.gz
Collecting pypiwin32 (from pyinstaller)
Downloading pypiwin32-223-py3-none-any.whl
Collecting altgraph>=0.15 (from macholib>=1.8->pyinstaller)
Using cached altgraph-0.15-py2.py3-none-any.whl
Collecting pywin32>=223 (from pypiwin32->pyinstaller)
Downloading pywin32-223-cp36-cp36m-win_amd64.whl (9.0MB)
100% |████████████████████████████████| 9.0MB 75kB/s
Installing collected packages: future, pefile, altgraph, macholib, pywin32, pypiwin32, pyinstaller
Running setup.py install for future ... done
Running setup.py install for pefile ... done
Running setup.py install for pyinstaller ... done
Successfully installed altgraph-0.15 future-0.16.0 macholib-1.9 pefile-2017.11.5 pyinstaller-3.3.1 pypiwin32-223 pywin32-223 $ pip3 show pyinstaller
Name: PyInstaller
Version: 3.3.1
Summary: PyInstaller bundles a Python application and all its dependencies into a single package.
Home-page: http://www.pyinstaller.org
Author: Giovanni Bajo, Hartmut Goebel, David Vierra, David Cortesi, Martin Zibricky
Author-email: pyinstaller@googlegroups.com
License: GPL license with a special exception which allows to use PyInstaller to build and distribute non-free programs (including commercial ones)
Location: c:\python36\lib\site-packages
Requires: setuptools, pefile, macholib, future

3 - 使用Pyinstaller

3-1 文件及目录

通过“pyinstaller [...] scriptname”方式运行,将会默认生成以下文件及目录:

.spec

  • 打包配置文件,事后可删除
  • 控制参数:--specpath DIR Folder to store the generated spec file (default: current directory)
  • 使用pyinstaller时,默认会在当前的路径下生成一个以spec为后缀的打包配置文件,pyinstaller依据spec文件的内容来创建exe文件;
  • 正常情况下,不需要去修改这个spec文件,除非需要打包其他数据文件;

build/

  • 存放过程文件,事后可删除
  • 控制参数:--workpath WORKPATH Where to put all the temporary work files, .log, .pyz and etc. (default: .\build)

dist/

  • 存放捆绑的应用程序,包含生成好的exe文件
  • 控制参数:--distpath DIR Where to put the bundled app (default: .\dist)

3-2 常用命令选项

--distpath DIR        # 指定捆绑应用程序的存放路径和目录
--workpath WORKPATH # 指定存放临时文件的路径和目录
-y, --noconfirm # 无询问覆盖目录
--clean # 清除缓存文件
--log-level LEVEL # 指定日志等级 -D, --onedir # 生成一个包含exe文件和依赖文件的目录
-F, --onefile # 只生成一个包含依赖的exe格式文件
--specpath DIR # 指定存放spec文件的目录
-n NAME, --name NAME # 指定输出文件名称(默认为第一个文件名)
-c, --console, --nowindowed # 使用控制台(命令行窗口)作为标准IO(默认)
-w, --windowed, --noconsole # 不使用控制台(命令行窗口)作为标准IO(不适用*NIX系统)
-i <FILE.ico or FILE.exe,ID or FILE.icns>, --icon <FILE.ico or FILE.exe,ID or FILE.icns> # 指定应用ico图标 --add-data <SRC;DEST or SRC:DEST> # !
--add-binary <SRC;DEST or SRC:DEST> # !
-p DIR, --paths DIR # 指定搜索路径,用';'分割多个路径
--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 # 加密python字节码

4 - Pyinstaller示例

4-1 基本用法

python代码

guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ cat GUI_Tkinter.py
#! python3
# -*- coding: utf-8 -*-
from tkinter import *
import tkinter.messagebox as messagebox class Application(Frame): # 从Frame派生一个Application类,这是所有Widget的父容器
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack() # pack()方法把Widget加入到父容器中,并实现布局
self.createWidgets() def createWidgets(self):
self.helloLabel = Label(self, text='This is a sample.') # 创建一个Label
self.helloLabel.pack()
self.nameInput = Entry(self)
self.nameInput.pack()
self.alertButton = Button(self, text='Hi', command=self.hello) # 创建一个Button,点击按钮,触发hello()
self.alertButton.pack()
self.quitButton = Button(self, text='Quit', command=self.quit) # 点击按钮,触发self.quit(),程序退出
self.quitButton.pack() def hello(self):
name = self.nameInput.get() or 'world' # 获得用户输入的文本
messagebox.showinfo('Message', 'Hello, %s' % name) # 弹出消息对话框 app = Application() # 实例化Application
app.master.title('Hello World') # 设置窗口标题
app.mainloop() # 主消息循环 # ### Tkinter
# Python内置的是支持Tk的Tkinter,无需安装任何包,可以直接使用,能够满足基本的GUI程序的要求;
# 如果是非常复杂的GUI程序,建议用操作系统原生支持的语言和库来编写;
# 常见的第三方图形界面库包括Tk、wxWidgets、Qt、GTK等;

生成可执行文件

guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ ls -l
total 4
-rwxr-xr-x 1 guowli 1049089 1574 Feb 11 09:31 GUI_Tkinter.py* guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ pyinstaller -F -w GUI_Tkinter.py
205 INFO: PyInstaller: 3.3.1
207 INFO: Python: 2.7.12
207 INFO: Platform: Windows-7-6.1.7601-SP1
208 INFO: wrote D:\Anliven-Running\TempTest\GUI_Tkinter.spec
217 INFO: UPX is not available.
220 INFO: Extending PYTHONPATH with paths
['D:\\Anliven-Running\\TempTest', 'D:\\Anliven-Running\\TempTest']
223 INFO: checking Analysis
223 INFO: Building Analysis because out00-Analysis.toc is non existent
223 INFO: Initializing module dependency graph...
236 INFO: Initializing module graph hooks...
365 INFO: running Analysis out00-Analysis.toc
392 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
required by c:\python27\python.exe
2701 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest
2705 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_acd0e4ffe1daef0a.manifest
2710 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_acd19a1fe1da248a.manifest
2806 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4940_none ...
2806 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c.manifest
2809 INFO: Searching for file msvcr90.dll
2809 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcr90.dll
2810 INFO: Searching for file msvcp90.dll
2810 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcp90.dll
2812 INFO: Searching for file msvcm90.dll
2812 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcm90.dll
2908 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest
2909 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_acd0e4ffe1daef0a.manifest
2911 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_acd19a1fe1da248a.manifest
2912 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 4940)
3044 INFO: Caching module hooks...
3070 INFO: Analyzing D:\Anliven-Running\TempTest\GUI_Tkinter.py
8287 INFO: Processing pre-safe import module hook _xmlplus
8536 INFO: Processing pre-find module path hook distutils
9615 INFO: Loading module hooks...
9615 INFO: Loading module hook "hook-distutils.py"...
9618 INFO: Loading module hook "hook-sysconfig.py"...
9619 INFO: Loading module hook "hook-xml.py"...
9769 INFO: Loading module hook "hook-httplib.py"...
9770 INFO: Loading module hook "hook-_tkinter.py"...
10214 INFO: checking Tree
10217 INFO: Building Tree because out00-Tree.toc is non existent
10217 INFO: Building Tree out00-Tree.toc
10470 INFO: checking Tree
10470 INFO: Building Tree because out01-Tree.toc is non existent
10470 INFO: Building Tree out01-Tree.toc
10498 INFO: Loading module hook "hook-encodings.py"...
11378 INFO: Looking for ctypes DLLs
11409 INFO: Analyzing run-time hooks ...
11412 INFO: Including run-time hook 'pyi_rth__tkinter.py'
11421 INFO: Looking for dynamic libraries
11786 INFO: Looking for eggs
11787 INFO: Using Python library C:\WINDOWS\system32\python27.dll
11787 INFO: Found binding redirects:
[BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'amd64', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 4940), publicKeyToken=u'1fc8b3b9a1e18e3b')]
11796 INFO: Warnings written to D:\Anliven-Running\TempTest\build\GUI_Tkinter\warnGUI_Tkinter.txt
11839 INFO: Graph cross-reference written to D:\Anliven-Running\TempTest\build\GUI_Tkinter\xref-GUI_Tkinter.html
12016 INFO: checking PYZ
12016 INFO: Building PYZ because out00-PYZ.toc is non existent
12017 INFO: Building PYZ (ZlibArchive) D:\Anliven-Running\TempTest\build\GUI_Tkinter\out00-PYZ.pyz
12598 INFO: Building PYZ (ZlibArchive) D:\Anliven-Running\TempTest\build\GUI_Tkinter\out00-PYZ.pyz completed successfully.
12664 INFO: checking PKG
12664 INFO: Building PKG because out00-PKG.toc is non existent
12664 INFO: Building PKG (CArchive) out00-PKG.pkg
12828 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 4940)
16441 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
16570 INFO: Bootloader c:\python27\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
16570 INFO: checking EXE
16572 INFO: Building EXE because out00-EXE.toc is non existent
16572 INFO: Building EXE from out00-EXE.toc
16573 INFO: Appending archive to EXE D:\Anliven-Running\TempTest\dist\GUI_Tkinter.exe
16603 INFO: Building EXE from out00-EXE.toc completed successfully. guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ ls -l
total 8
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:09 build/
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:09 dist/
-rwxr-xr-x 1 guowli 1049089 1574 Feb 11 09:31 GUI_Tkinter.py*
-rw-r--r-- 1 guowli 1049089 767 Feb 27 15:09 GUI_Tkinter.spec guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ ls -lR
.:
total 8
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:09 build/
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:09 dist/
-rwxr-xr-x 1 guowli 1049089 1574 Feb 11 09:31 GUI_Tkinter.py*
-rw-r--r-- 1 guowli 1049089 767 Feb 27 15:09 GUI_Tkinter.spec ./build:
total 4
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:09 GUI_Tkinter/ ./build/GUI_Tkinter:
total 10400
-rw-r--r-- 1 guowli 1049089 1351 Feb 27 15:09 GUI_Tkinter.exe.manifest
-rw-r--r-- 1 guowli 1049089 118100 Feb 27 15:09 out00-Analysis.toc
-rw-r--r-- 1 guowli 1049089 91969 Feb 27 15:09 out00-EXE.toc
-rw-r--r-- 1 guowli 1049089 8490727 Feb 27 15:09 out00-PKG.pkg
-rw-r--r-- 1 guowli 1049089 90661 Feb 27 15:09 out00-PKG.toc
-rw-r--r-- 1 guowli 1049089 1396916 Feb 27 15:09 out00-PYZ.pyz
-rw-r--r-- 1 guowli 1049089 28133 Feb 27 15:09 out00-PYZ.toc
-rw-r--r-- 1 guowli 1049089 80981 Feb 27 15:09 out00-Tree.toc
-rw-r--r-- 1 guowli 1049089 6778 Feb 27 15:09 out01-Tree.toc
-rw-r--r-- 1 guowli 1049089 2866 Feb 27 15:09 warnGUI_Tkinter.txt
-rw-r--r-- 1 guowli 1049089 322575 Feb 27 15:09 xref-GUI_Tkinter.html ./dist:
total 8560
-rwxr-xr-x 1 guowli 1049089 8762599 Feb 27 15:09 GUI_Tkinter.exe* guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$

运行可执行文件

4-2 自定义ico图标

图标下载:https://www.easyicon.net/

生成可执行文件

guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ pyinstaller -F -w -i panda.ico GUI_Tkinter.py
279 INFO: PyInstaller: 3.3.1
279 INFO: Python: 2.7.12
279 INFO: Platform: Windows-7-6.1.7601-SP1
280 INFO: wrote D:\Anliven-Running\TempTest\GUI_Tkinter.spec
......
......
......
13562 INFO: Appending archive to EXE D:\Anliven-Running\TempTest\dist\GUI_Tkinter.exe
13578 INFO: Building EXE from out00-EXE.toc completed successfully. guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$ ls -lR
.:
total 76
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:39 build/
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:40 dist/
-rwxr-xr-x 1 guowli 1049089 1574 Feb 11 09:31 GUI_Tkinter.py*
-rw-r--r-- 1 guowli 1049089 785 Feb 27 15:39 GUI_Tkinter.spec
-rw-r--r-- 1 guowli 1049089 67646 Feb 27 15:37 panda.ico ./build:
total 4
drwxr-xr-x 1 guowli 1049089 0 Feb 27 15:40 GUI_Tkinter/ ./build/GUI_Tkinter:
total 10400
-rw-r--r-- 1 guowli 1049089 1351 Feb 27 15:40 GUI_Tkinter.exe.manifest
-rw-r--r-- 1 guowli 1049089 118100 Feb 27 15:40 out00-Analysis.toc
-rw-r--r-- 1 guowli 1049089 91976 Feb 27 15:40 out00-EXE.toc
-rw-r--r-- 1 guowli 1049089 8490727 Feb 27 15:40 out00-PKG.pkg
-rw-r--r-- 1 guowli 1049089 90661 Feb 27 15:40 out00-PKG.toc
-rw-r--r-- 1 guowli 1049089 1396916 Feb 27 15:40 out00-PYZ.pyz
-rw-r--r-- 1 guowli 1049089 28133 Feb 27 15:40 out00-PYZ.toc
-rw-r--r-- 1 guowli 1049089 80981 Feb 27 15:40 out00-Tree.toc
-rw-r--r-- 1 guowli 1049089 6778 Feb 27 15:40 out01-Tree.toc
-rw-r--r-- 1 guowli 1049089 2866 Feb 27 15:40 warnGUI_Tkinter.txt
-rw-r--r-- 1 guowli 1049089 322575 Feb 27 15:40 xref-GUI_Tkinter.html ./dist:
total 8620
-rwxr-xr-x 1 guowli 1049089 8826599 Feb 27 15:40 GUI_Tkinter.exe* guowli@5CG450158J MINGW64 /d/Anliven-Running/TempTest
$

运行可执行文件

5 - Tips

5-1 onefolder模式

参数:-D, --onedir # 生成一个包含exe文件和依赖文件的目录

onefolder模式可以用于确认打包是否完整正确。

打包成onefile文件时,发布前最好先打包成onefolder,检查一下需要的文件是否被正确打包。

5-2 打包IDE编写的python文件

在类似Pycharm导入的模块可能并没有安装到本地的python环境,就会导致在python文件在PyCharm中能正常运行但在命令行运行报错的现象。

在使用pyinstaller打包时,对应的现象就是:执行EXE文件闪退,或提示ImportError错误。

此问题只需要使用pip安装相应模块再打包即可。

5-3 加密python字节码

利用加密参数 --key ,可自定义一个16位密钥来加密pyc文件,加大反编译难度。

注意:必须事先安装PyCrypto(https://pypi.python.org/pypi/pycrypto/)。

官方文档:https://pyinstaller.readthedocs.io/en/stable/usage.html#encrypting-python-bytecode

To encrypt the Python bytecode modules stored in the bundle, pass the --key=key-string argument on the command line.

For this to work, you must have the PyCrypto module installed. The key-string is a string of 16 characters which is used to encrypt each file of Python byte-code before it is stored in the archive inside the executable file.

5-4 文件名称及路径

  • 文件路径中不能出现空格和英文句号;
  • 源文件必须是UTF-8编码,暂不支持其他编码类型;

5-5 报错信息

如果执行生成的exe文件闪退,没有报错信息,可以尝试在cmd命令中运行exe文件,可能会看到报错原因。

5-6 关于跨平台

虽然Pyinstaller是跨平台的,但是打包之后的exe文件并不能跨平台执行。

在Windows系统下打包生成的exe文件只能在Windows系统下运行,同理在Linux下打包生成的exe文件也只能在Linux下运行。

如果将在Windows系统下打包生成的exe文件在Linux下运行,将会报错“Exec format error. Binary file not executable”。

6 - 帮助信息

-h, --help # 显示帮助信息

$ pyinstaller -h
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] [-s] [--noupx] [-c] [-w]
[-i <FILE.ico or FILE.exe,ID or FILE.icns>]
[--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
[--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
[--win-no-prefer-redirects]
[--osx-bundle-identifier BUNDLE_IDENTIFIER]
[--runtime-tmpdir PATH] [--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, --debug Tell the bootloader to issue progress messages while
initializing and starting the bundled app. Used to
diagnose problems with missing imports.
-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) Windows and Mac OS X specific options:
-c, --console, --nowindowed
Open a console window for standard i/o (default)
-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. This option is ignored
in *NIX systems.
-i <FILE.ico or FILE.exe,ID or FILE.icns>, --icon <FILE.ico or FILE.exe,ID or FILE.icns>
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 Windows specific options:
--version-file FILE add a version resource from FILE to the exe
-m <FILE or XML>, --manifest <FILE or XML>
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.

Python - 使用Pyinstaller将Python代码生成可执行文件的更多相关文章

  1. pyinstaller使用-python项目转换成exe可执行文件

    http://blog.csdn.net/pipisorry/article/details/50620122 Python不是每个人的计算机里面都有安装,当您写了一个好用的工具,需要一个standa ...

  2. 用PyInstaller把Python代码打包成单个独立的exe可执行文件

    之前就想要把自己的BlogsToWordpress打开成exe了.一直没去弄. 又看到有人提到python打开成exe的问题. 所以打算现在就去试试. 注:此处之所有选用BlogsToWordpres ...

  3. python开发环境配置和python源码打包生成exe可执行文件

    Windows下开发环境准备 1.分别安装:python2和python32.安装Python的集成工具:Anaconda3.安装Pycharm Pycharm设置 设置: File->Sett ...

  4. PyInstaller打包python脚本的一些心得

    PyInstaller打包python脚本的一些心得 因为在公司经常要帮同事做一个从excel表格中提取出需要的内容的重复工作,比较繁琐还容易出错:于是就想着要写个程序,但是同事又不可能在电脑上也装上 ...

  5. 树莓派(Raspbian系统)中使用pyinstaller封装Python代码为可执行程序

    一.前言 将做好的Python软件运行在树莓派上时,不想公开源码,就需要对文件进行封装(或称打包),本文主要介绍使用pyinstaller封装Python代码为可执行程序. Python是一个脚本语言 ...

  6. (转)使用 PyInstaller 把python程序 .py转为 .exe 可执行程序

    最近使用Python为项目开发一款绘图工具(绘出 声场三维模型).因为希望能把Python脚本发布为脱离Python平台运行的可执行程序,比如单个的exe文件.PyInstaller恰满足这个需求.本 ...

  7. pyinstaller打包python文件成exe(原理.安装.问题)

    py文件打包成exe文件的方式一共有三种:py2exe.PyInstaller和cx_Freeze 本文分四个步骤来详讲如何用PyInstaller将py文件打包成exe文件 1. PyInstall ...

  8. 【Python开发】PyInstaller打包Python程序

    PyInstaller是一个能将Python程序转换成单个可执行文件的程序, 操作系统支持Windows, Linux, Mac OS X, Solaris和AIX.并且很多包都支持开箱即用,不依赖环 ...

  9. pyinstaller 还原python代码的方法

    pyinstaller 的作用就是将python打包成对应平台的可执行文件.一般这种可执行文件的体积都比较大. 我们可以先通过逆向软件查看一下具体信息 查看字符串信息 只要有诸如以上的字符串 就说明这 ...

随机推荐

  1. myeclise 安装

    安装.破解步骤都在gaobo百度云/工具/开发工具 安装后配置环境变量:

  2. SAP 图形页面

    话不多说,先上炫图. *&---------------------------------------------------------------------* *& Repor ...

  3. 绑定checkedComboBox

    using System; namespace CommonLib{ /// <summary> /// CommonCode 的摘要说明. /// </summary> [S ...

  4. 定时任务APScheduler

    安装 APScheduler $ pip install apscheduler 快速开始 from apscheduler.schedulers.blocking import BlockingSc ...

  5. Apache无法正常启动(配置多个监听端口)

    Apache监测多个端口配置: 1.conf->extra->httpd-vhosts.conf  检查配置项是否写错 2.http.conf listen端口是否监听正确 3.环境变量中 ...

  6. 20175234 《Java程序设计》第二周学习总结(二)

    学习内容总结 运算符与表达式 If语句.switch语句 break和continue语句 数组和for语句 IDEA的安装和调试 教材学习中的问题和解决过程 在第一次使用IDEA中出现了一些情况,在 ...

  7. [快速幂][NOIP2012]转圈游戏

    转圈游戏 题目描述 n 个小伙伴(编号从 0 到 n-1)围坐一圈玩游戏.按照顺时针方向给 n 个位置编号,从0 到 n-1.最初,第 0 号小伙伴在第 0 号位置,第 1 号小伙伴在第 1 号位置, ...

  8. cpp 区块链模拟示例(一)工程建立

    /* 作 者: itdef 欢迎转帖 请保持文本完整并注明出处 技术博客 http://www.cnblogs.com/itdef/ 技术交流群 群号码:432336863欢迎c c++ window ...

  9. Netsharp总体介绍

    作者:秋时   日期:2014年02月05日   转载须说明出处  Netsharp交流群:338963050(请有详细的请求说明) Netsharp系列文章目录结构 Netsharp是一款免费的基于 ...

  10. MybatisMapper 映射框架(增删改查 原始模式)

    //增删改查 package TestDemo; import java.io.IOException; import java.io.InputStream; import java.util.Da ...