最近用 wxpython写了一个小的脚本,因为想要发布给没有装python和wxpython的人使用,遂决定使用pyinstaller 2.1进行打包。
其中遇到几个问题:
1,给打包的文件添加图标
查看pyinstaller 的操作手册很容易发现:
-i , -i , --icon=, --icon=
Add an icon to the output executable. Specify an icon FILE.ico to use that icon. Specify an existing .exe file giving the ID to extract the icon with that ID.
可以在使用的时候,在命令行中执行,不过更推荐的是使用bat文件来执行
python pyinstaller.py --icon=targetico_path.ico--onefile --windowed target_py_file.py进行打包
2,给打包的程序添加版本信息
查看pyinstaller 操作手册发现:
--version-file=version_text_file
Add a Version resource to the .exe output using a version_text_file as produced by pyi-grab_version.
也就是说要添加版本信息需要指定一个版本信息文件,版本信息文件操作手册中也给了制作方法
pyi-grab_versionexecutable_with_version_resource
The pyi-grab_version command is invoked with the full path