Python项目打包成exe文件的具体操作是什么
Admin 2022-06-22 群英技术资讯 326 次浏览
如果python项目打包exe呢?下面按照步骤讲解一下。
安装pyinstaller。
pip install pyinstaller -i https://pypi.douban.com/simple
项目部分代码
先看一下项目在终端执行的效果。
使用pyinstaller命令在打包将main方法打包。
pyinstaller -F main.py
打包过程
C:\Users\yi\PycharmProjects\txl>pyinstaller -F main.py 143 INFO: PyInstaller: 4.7 143 INFO: Python: 3.7.6 144 INFO: Platform: Windows-10-10.0.19041-SP0 145 INFO: wrote C:\Users\yi\PycharmProjects\txl\main.spec 162 INFO: UPX is not available. 165 INFO: Extending PYTHONPATH with paths ['C:\\Users\\yi\\PycharmProjects\\txl'] 640 INFO: checking Analysis 641 INFO: Building Analysis because Analysis-00.toc is non existent 641 INFO: Initializing module dependency graph... 649 INFO: Caching module graph hooks... 696 INFO: Analyzing base_library.zip ... 4371 INFO: Caching module dependency graph... 4614 INFO: running Analysis Analysis-00.toc 4619 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable required by c:\users\yi\appdata\local\programs\python\python37\python.exe 5046 INFO: Analyzing C:\Users\yi\PycharmProjects\txl\main.py 5049 INFO: Processing module hooks... 5050 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks'... 5052 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks'... 5253 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks'... 5256 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks'... 5260 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks'... 5529 INFO: Looking for ctypes DLLs 5529 INFO: Analyzing run-time hooks ... 5532 INFO: Including run-time hook 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py' 5535 INFO: Including run-time hook 'c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py' 5542 INFO: Looking for dynamic libraries 5721 INFO: Looking for eggs 5722 INFO: Using Python library c:\users\yi\appdata\local\programs\python\python37\python37.dll 5722 INFO: Found binding redirects: [] 5726 INFO: Warnings written to C:\Users\yi\PycharmProjects\txl\build\main\warn-main.txt 5765 INFO: Graph cross-reference written to C:\Users\yi\PycharmProjects\txl\build\main\xref-main.html 5782 INFO: checking PYZ 5783 INFO: Building PYZ because PYZ-00.toc is non existent 5783 INFO: Building PYZ (ZlibArchive) C:\Users\yi\PycharmProjects\txl\build\main\PYZ-00.pyz 6170 INFO: Building PYZ (ZlibArchive) C:\Users\yi\PycharmProjects\txl\build\main\PYZ-00.pyz completed successfully. 6182 INFO: checking PKG 6182 INFO: Building PKG because PKG-00.toc is non existent 6182 INFO: Building PKG (CArchive) main.pkg 7800 INFO: Building PKG (CArchive) main.pkg completed successfully. 7803 INFO: Bootloader c:\users\yi\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe 7803 INFO: checking EXE 7803 INFO: Building EXE because EXE-00.toc is non existent 7804 INFO: Building EXE from EXE-00.toc 7805 INFO: Copying bootloader EXE to C:\Users\yi\PycharmProjects\txl\dist\main.exe 7897 INFO: Copying icon to EXE 7897 INFO: Copying icons from ['c:\\users\\yi\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico'] 7996 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes 7996 INFO: Writing RT_ICON 1 resource with 3752 bytes 7997 INFO: Writing RT_ICON 2 resource with 2216 bytes 7997 INFO: Writing RT_ICON 3 resource with 1384 bytes 7997 INFO: Writing RT_ICON 4 resource with 37019 bytes 7997 INFO: Writing RT_ICON 5 resource with 9640 bytes 7998 INFO: Writing RT_ICON 6 resource with 4264 bytes 7998 INFO: Writing RT_ICON 7 resource with 1128 bytes 8002 INFO: Copying 0 resources to EXE 8003 INFO: Emedding manifest in EXE 8004 INFO: Updating manifest in C:\Users\yi\PycharmProjects\txl\dist\main.exe 8007 INFO: Updating resource type 24 name 1 language 0 8011 INFO: Appending PKG archive to EXE 9702 INFO: Building EXE from EXE-00.toc completed successfully. C:\Users\yi\PycharmProjects\txl>
会在dist生成exe文件,就是我们要的。
双击执行一下
没啥总结的,做个记录。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了Python数据分析之PMI数据图形展示,文章介绍了简单的python爬虫,并使用numpy进行了简单的数据处理,最终使用 matplotlib 进行图形绘制,实现了直观的方式展示制造业和非制造业指数图形,需要的朋友可以参考一下
python怎样读取pdf本文内容?一些新手可能对于python读取pdf文本内容不是很清楚,因此下面给大家分享python读取pdf文档的实现代码,有这方面学习需要的朋友可以参考学习。
这篇文章介绍了Python中的基本数据类型,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
如何通过装饰器实现已有函数执行时间的统计?废话不多说,下面直接上代码
1、collections--基于Python自带的数据类型之上额外增加的几个数据类型fromcollectionsimport*在内置数据类型(dict、list、set、tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter、deque、defaultdict、namedtuple和OrderedDict以及判断什么是可迭
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008