pyinstaller常用參數
- -w 不顯示控制台
- -D 單一目錄
- -F 單一檔案。但啟動速度超級慢(約5秒)。有查到補上 --noupx會正常,實測後仍要5秒多才能正常啟動。目前似乎是無解…可惜啊><
- –icon=圖標路徑
- –version-file=file_version_info.txt。執行檔右鍵詳細資料的明細內容
pyinstaller -w -D --icon=icon.ico --version-file=file_version_info.txt main.py
其中file_version_info.txt的內容格式可以由pyinstaller提供的grab_version.py可以取得
所以使用之版本:Python 3.6.5,pyinstaller 3.3.1
為截至po文時的最新版本
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(1, 1, 0, 0),
prodvers=(1, 1, 0, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x0,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x4,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'000004e6',
[StringStruct(u'Comments', u'comments'),
StringStruct(u'CompanyName', u'CompanyName'),
StringStruct(u'FileDescription', u'FileDescription'),
StringStruct(u'FileVersion', u'1.2'),
StringStruct(u'InternalName', u'InternalName'),
StringStruct(u'LegalCopyright', u'LegalCopyright'),
StringStruct(u'OriginalFilename', u'OriginalFilename'),
StringStruct(u'ProductName', u'ProductName'),
StringStruct(u'ProductVersion', u'1.2')])
]),
VarFileInfo([VarStruct(u'Translation', [0, 1254])])
]
)
若之後版本更新而不能使用的話打開CMD,CD到Python安裝目錄下
cd Lib/site-packages/PyInstaller-3.3.1-py3.6.egg/PyInstaller/utils/cliutils/
輸入python grab_version.py 拖曳任一安裝或免安裝的exe檔到CMD
會自動產生file_version_info.txt再將內容修改成自己要的資訊就可以使用了!
留言
張貼留言