python 将python程序编译成可
短信预约 -IT技能 免费直播动态提醒
一、使用pyinstaller 完成对python程序到可执行文件转换.
官网: http://www.pyinstaller.org/ 下载与操作系统相匹配的版本. 目前pyinstaller 只支持2.3 - 2.7。 不支持python.3
二、将下载的pyinstaller-2.0.zip文件解压,解压后可直接使用。
pyinstaller不依赖python,因此不需要放入到 site-packages此目录.
三、pyinstaller 使用及参数
- C:\pyinstaller-2.0>python pyinstaller.py -F -w --icon=E:\p_w_picpaths\96.ico MonitorWin32Process.py
- 38 INFO: wrote C:\pyinstaller-2.0\MonitorWin32Process\MonitorWin32Process.spec
- 60 INFO: Testing for ability to set icons, version resources...
- 75 INFO: ... resource update available
- 78 INFO: UPX is not available.
- 1154 INFO: checking Analysis
- 1156 INFO: building Analysis because out00-Analysis.toc non existent
- 1157 INFO: running Analysis out00-Analysis.toc
- 1159 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
-
- 1253 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21
- 022.8_none ...
- 1255 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc
- 8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest
- 1258 INFO: Searching for file msvcr90.dll
- 1259 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
- 9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
- 1259 INFO: Searching for file msvcp90.dll
- 1261 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
- 9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
- 1262 INFO: Searching for file msvcm90.dll
- 1264 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
- 9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
- 1365 INFO: Analyzing C:\pyinstaller-2.0\support\_pyi_bootstrap.py
- 2440 INFO: Analyzing C:\pyinstaller-2.0\PyInstaller\loader\archive.py
- 2552 INFO: Analyzing C:\pyinstaller-2.0\PyInstaller\loader\carchive.py
- 2674 INFO: Analyzing C:\pyinstaller-2.0\PyInstaller\loader\iu.py
- 2705 INFO: Analyzing MonitorWin32Process.py
- 2779 WARNING: pywintypes is changing its name to pywintypes27
- 2871 WARNING: pythoncom is changing its name to pythoncom27
- 3535 INFO: Hidden import 'encodings' has been found otherwise
- 3536 INFO: Looking for run-time hooks
- 3537 INFO: Analyzing rthook C:\pyinstaller-2.0\support/rthooks/pyi_rth_encodings
- .py
- 3621 INFO: Analyzing rthook C:\pyinstaller-2.0\support/rthooks/pyi_rth_versioned
- dll.py
- 3723 INFO: Analyzing rthook C:\pyinstaller-2.0\support/rthooks/pyi_rth_win32comg
- enpy.py
- 3833 INFO: Analyzing rthook C:\pyinstaller-2.0\support/rthooks/pyi_rth_versioned
- dll.py
- 4118 INFO: Adding Microsoft.VC90.MFC to dependent assemblies of final executable
-
- 4192 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.21
- 022.8_none ...
- 4193 INFO: Found manifest C:\Python27\lib\site-packages\Pythonwin\Microsoft.VC90
- .MFC.manifest
- 4195 INFO: Searching for file mfc90.dll
- 4196 INFO: Found file C:\Python27\lib\site-packages\Pythonwin\mfc90.dll
- 4197 INFO: Searching for file mfc90u.dll
- 4197 INFO: Found file C:\Python27\lib\site-packages\Pythonwin\mfc90u.dll
- 4199 INFO: Searching for file mfcm90.dll
- 4200 INFO: Found file C:\Python27\lib\site-packages\Pythonwin\mfcm90.dll
- 4200 INFO: Searching for file mfcm90u.dll
- 4202 INFO: Found file C:\Python27\lib\site-packages\Pythonwin\mfcm90u.dll
- 4856 INFO: Warnings written to C:\pyinstaller-2.0\MonitorWin32Process\build\pyi.
- win32\MonitorWin32Process\warnMonitorWin32Process.txt
- 4866 INFO: checking PYZ
- 4867 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
- 4868 INFO: building PYZ out00-PYZ.toc
- 6252 INFO: checking PKG
- 6253 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
- 6253 INFO: building PKG out00-PKG.pkg
- 8202 INFO: checking EXE
- 8203 INFO: rebuilding out00-EXE.toc because MonitorWin32Process.exe missing
- 8205 INFO: building EXE from out00-EXE.toc
- 8212 INFO: class="lazy" data-srcPATH [('E:\\p_w_picpaths\\96.ico', None)]
- 8231 INFO: Updating icons from ['E:\\p_w_picpaths\\96.ico'] to c:\users\bo\appdata\loc
- al\temp\tmp827iux
- 8232 INFO: Writing RT_GROUP_ICON 0 resource with 76 bytes
- 8233 INFO: Writing RT_ICON 1 resource with 872 bytes
- 8233 INFO: Writing RT_ICON 2 resource with 3240 bytes
- 8235 INFO: Writing RT_ICON 3 resource with 7336 bytes
- 8236 INFO: Writing RT_ICON 4 resource with 12840 bytes
- 8236 INFO: Writing RT_ICON 5 resource with 28840 bytes
- 8266 INFO: Appending archive to EXE C:\pyinstaller-2.0\MonitorWin32Process\dist\
- MonitorWin32Process.exe
-
- C:\pyinstaller-2.0>
正常情况下会在当前目录下,生成与python文件名相同的目录,可执行程序在dist 目录下.
- -F 生成一个文件及生成一个exe文件
- -W --windowed, --noconsole 使用一个子系统,不使用console及没有那个黑框
- --icon 可自定义图标
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341