是否有一种方法可以使用给定的过程描述来编译Python脚本?例如,我有一个名为“ main.py”的文件,编译后我有“ main.exe”。当我运行脚本时,它在任务管理器中显示“ main”,但是我想要“ My python script”之类的东西。 PyInstaller可以吗?
当然可以。您需要做的是(请参阅here获取文档):
exe
文件,该文件包含您想要的exe
的元数据类别pyi-grab_version C:\path\to\that\file.exe
file_version_info.txt
pyinstaller --version-file=file_version_info.txt main.py
如果您使用pyinstaller规范文件生成exe,则可以用此步骤4代替。
version='file_version_info.txt'
文件中添加main.spec
:exe = EXE(... ... version='file_version_info.txt' )
并运行pyinstaller main.spec
。
示例
在您的情况下,要在file_version_info.txt
中编辑的元数据类别为FileDescription
。参见下面的file_version_info.txt
文件示例:
# 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, 2, 3, 0),
prodvers=(1, 2, 3, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# 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=0x40004,
# 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'040904b0',
[StringStruct(u'CompanyName', u'MyCompany'),
StringStruct(u'FileDescription', u'MyApp'),
StringStruct(u'FileVersion', u'1.23.0'),
StringStruct(u'InternalName', u'cardprocess'),
StringStruct(u'LegalCopyright', u'No Copyright © 2020'),
StringStruct(u'OriginalFilename', u'myapp.exe'),
StringStruct(u'ProductName', u'myapp'),
StringStruct(u'ProductVersion', u'1.23.0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)