设为首页 收藏本站
查看: 1287|回复: 0

[经验分享] python 将python程序编译成可执行文件

[复制链接]

尚未签到

发表于 2018-8-4 11:14:44 | 显示全部楼层 |阅读模式
  一、使用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:\images\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: SRCPATH [('E:\\images\\96.ico', None)]
  • 8231 INFO: Updating icons from ['E:\\images\\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 可自定义图标
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-546400-1-1.html 上篇帖子: python 建立简单的web服务器 下篇帖子: Python爬虫入门 | 1 Python环境的安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表