,-i,--icon=,--icon=Addanicontotheoutputexecutable.Specifyanicon" />

欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

使用pyinstaller 2.1將python打包并添加版本信

系統 2288 0

  最近用 wxpython寫了一個小的腳本,因為想要發布給沒有裝python和wxpython的人使用,遂決定使用pyinstaller 2.1進行打包。

其中遇到幾個問題:

1,給打包的文件添加圖標

  查看pyinstaller 的操作手冊很容易發現:

-i? <FILE.ico> ,? -i? <FILE.exe,ID> ,? --icon= <FILE.ico> ,? --icon= <FILE.exe,ID>
? 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 .?

  也就是說要添加版本信息需要指定一個版本信息文件,版本信息文件操作手冊中也給了制作方法

Capturing Version Data

pyi-grab_version? executable_with_version_resource

The? pyi-grab_version ?command is invoked with the full path name of a Windows executable that has a Version resource. (A Version resource contains a group of data structures, some containing binary integers and some containing strings, that describe the properties of the executable. For details see the? Version Information Structures ?page.)

The command writes text that represents a Version resource in readable form. The version text is written to standard output. You can copy it from the console window or redirect it to a file. Then you can edit the version information to adapt it to your program. This approach is used because version resources are complex. Some elements are optional, others required. When you view the version tab of a Properties dialog, there's no simple relationship between the data displayed and the structure of the resource. Using? pyi-grab_version ?you can find an executable that displays the kind of information you want, copy its resource data, and modify it to suit your package.

The version text file is encoded UTF-8 and may contain non-ASCII characters. (Unicode characters are allowed in Version resource string fields.) Be sure to edit and save the text file in UTF-8 unless you are certain it contains only ASCII string values.

The edited version text file can be given with a? --version-file= ?option to? pyinstaller ?or? pyi-makespec . The text data is converted to a Version resource and installed in the executable output.

In a Version resource there are two 64-bit binary values,? FileVersion ?and? ProductVersion . In the version text file these are given as four-element tuples, for example:

      filevers=(2, 0, 4, 0),

prodvers=(2, 0, 4, 0),


    

The elements of each tuple represent 16-bit values from most-significant to least-significant. For example the? FileVersion ?value given resolves to? 0002000000040000 ?in hex.

set_version ? version_text_file ? executable_file

The? set_version ?utility reads a version text file as written by? pyi-grab_version , converts it to a Version resource, and installs that resource in the? executable_file ?specified.

For advanced uses, examine a version text file. You find it is Python code that creates a? VSVersionInfo ?object. The class definition for? VSVersionInfo ?is found in? utils/versioninfo.py ?in the PyInstaller ?distribution folder. You can write a program that imports that module. In that program you can? eval ?the contents of a version info text file to produce a? VSVersionInfo ?object. You can use the? .toRaw() ?method of that object to produce a Version resource in binary form. Or you can apply the? unicode() ?function to the object to reproduce the version text file.

?

  上面的意思呢就是使用pyinstaller內置的grab_version.py工具獲得其他.exe程序的版本信息文件,版本信息文件里面包括公司名,程序內部名稱版本號之類,然后再把這個信息里面的相關信息更改成你想要的信息,再使用上面的--version-file= version_text_file  參數的把版本信息注射到.exe中去。

  其中注意因為這個版本信息是嚴格的數據結構,所以最好不要用notepad打開,有可能導致版本信息文件失效,我用的是notepad++更改,實測有用。

  其中grab_version.py的位置在.\PyInstaller-2.1\utils,pyinstaller 2.1根目錄下的utils目錄下。

  可以在使用的時候,在命令行中執行,需要將當前路徑轉到該腳本所在地或者指定grab_version.py的路徑,不過更推薦的是使用bat文件來執行,只需要將下面字符保存到bat中方到grab_version.py文件里面去了:

  python?grab_version.py targetExe_path

  比如:

  python?grab_version.py?C:\Windows\System32\diskext.exe

  產生的版本信息文件就在程序的當前目錄下,更改好版本信息文件之后就可以開始使用了 

  python pyinstaller.py --version-file=file_version_info.txt --icon=ico.ico --onefile --windowed target.py

  OK,問題解決。

?

使用pyinstaller 2.1將python打包并添加版本信息和圖標


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 欧美特级限制片高清 | 欧美一级做a爰片免费视频 亚洲男人的天堂久久精品 色吟av | 欧美日韩性猛交xxxxx免费看 | 欧美在线视频一区 | 亚洲人人 | 色婷婷久久综合中文久久一本 | 免费久久精品国产片香蕉 | 国产一级特黄aa大片免费 | 国产一级特黄毛片在线毛片 | 拍拍拍无挡免费视频网站 | 日本高清无卡码一区二区久久 | 狠狠色丁香婷婷综合久久片 | 无人精品乱码一区二区三区 | 一级黄色片毛片 | 亚洲经典激情春色另类 | 欧美特黄一级视频 | 国产高清中文字幕 | 免费人成年短视频在线观看免费网站 | 国变精品美女久久久久av爽 | 精品成人一区 | 国产精品视频播放 | 日韩中文字幕视频在线 | 久久久精 | 免费观看一级欧美在线视频 | 无码色情影片视频在线看免费 | 99青青青精品视频在线 | 国产欧美日韩一区二区三区四区 | 久久综合久色欧美综合狠狠 | 免费人成在线播放 | 久久人 | 欧美精彩视频在线观看 | 99青青青精品视频在线 | 日韩日b视频 | 国产一级毛片在线看 | 亚洲国产精品久久网午夜 | 97丨九色丨国产人妻熟女 | 亚洲阿v天堂2021在线观看 | 欧美a视频在线观看 | 蜜桃传媒一区二区亚洲AV | 一级毛片丰满 出奶水 | 欧美日韩中文字幕一区二区高清 |