博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pyqt pyinstaller使用说明
阅读量:4683 次
发布时间:2019-06-09

本文共 7488 字,大约阅读时间需要 24 分钟。

一、实验环境

1.Windows7x64_SP1

2.anaconda2.5.0 + python2.7(anaconda集成,不需单独安装)

3.pyinstaller3.0

最新3.5存在问题,最新3.5存在问题,最新3.5存在问题,重要的事情说三遍!

安装最新的pyinstaller3.5,打包运行正常,但运行程序报错,弹出对话框提示Fatal Error,做如下debug:

1.使用管理员权限运行cmd,输入如下命令

pyinstaller -D smartbit_tool.py -w -i .\ico\magnifier.ico

运行程序依然报错,弹出对话框提示Fatal Error,看来不是cmd权限不够问题

2.pyinstaller打包参数中打开控制台,命令如下

pyinstaller -D smartbit_tool.py -i .\ico\magnifier.ico

运行程序依然报错,弹出的控制台一闪而过,无法看清具体出错信息

在批处理中执行如上程序,终于看到报错信息,提示pyinstaller未找到sip模块,Google后发现pyinstaller会调用sip模块,非个人编写的程序代码。

于是卸载pyinstaller3.5,重新安装pyinstaller3.0,打包程序,程序运行正常。

二、实验步骤

2.1 pyinstaller帮助手册 ,可以使用如下命令查看

pyinstaller -h

 

帮助文档如下:

Usage: pyinstaller [opts] 
[
...] |
Options: -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=LOGLEVEL Amount of detail in build-time console messages (default: INFO, choose one of DEBUG, INFO, WARN, ERROR, CRITICAL) What to generate: -F, --onefile Create a one-file bundled executable. -D, --onedir Create a one-folder bundle containing an executable (default) --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: -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 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 (his Python names,not path names) that will be ignored (as thoughit 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
, --icon=
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
, --manifest=
add manifest FILE or XML to the exe -r
, --resource=
Add or update a resource of the given type, name and language from FILE to a Windows executable. 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) Obsolete options (not used anymore): -X, -K, -C, -o, --upx, --tk, --configfile, --skip-configure, --out, --buildpath These options do not exist anymore.

  

2.2 常用参数说明

  • -D 创建一个目录,里面包含exe以及其他一些依赖性文件
  • -F 表示生成单个可执行文件
  • -w 表示去掉控制台窗口,在GUI界面时非常有用
  • -i 表示可执行文件的图标,请使用*.ico格式图片

需要特别强调的是-i参数,可执行文件图标要求如下:

Windows XP:Explorer views:Details / List: 16Icons: 32Tiles / Thumbnails: 48Right-click->Properties / choosing a new icon: 32Quickstart area: 16Desktop: 32Windows 7:Explorer views:Details / List / Small symbols: 16All other options: 256 (resized, if necessary)Right-click->Properties / choosing a new icon: 32Pinned to taskbar: 32Right-click-menu: 16Desktop:Small symbols: 32Medium symbols: 48Large symbols: 256 (resized, if necessary)Zooming using Ctrl+Mouse wheel: 16, 32, 48, 256

Windows XP uses 16, 32, 48-size icons

while Windows 7 (and presumably also Vista) also uses 256-size icons. 所有中间尺寸会被过滤 

2.3 程序图标下载网站

提供各种尺寸图片下载,非常方便!

转载于:https://www.cnblogs.com/hester/p/11225993.html

你可能感兴趣的文章
Ubuntu 18.04 安卓调试小米
查看>>
MyBatis学习总结_06_调用存储过程
查看>>
SEO知识图一
查看>>
[开源JVM] yvm - 自制Java虚拟机
查看>>
Open vSwitch安装
查看>>
【Android】 No Activity found to handle Intent.
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
C++ sort简单用法
查看>>
IIS的ISAPI接口简介
查看>>
python:open/文件操作
查看>>
16 乘法口诀输出
查看>>
mac 常用地址
查看>>
鼠标经过切换图片
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>
windows live writer 2012 0x80070643
查看>>
C程序的启动和终止
查看>>
asp.net web 定时执行任务
查看>>
tomcat 和MySQL的安装
查看>>
11.5 内部类
查看>>