Python项⽬打包成exe⽂件
⽬录
前⾔
环境依赖
项⽬打包
总结
前⾔
之前有⼈私信我,他写了⼀个在终端交互的⼩程序,希望可以不在IDE的终端显⽰,⽽是独⽴⼀个窗⼝进⾏交互。其实只要把项⽬打包成exe执⾏⽂件,就可以在执⾏的时候在cmd独⽴⼀个窗⼝了。
如果python项⽬打包exe呢?下⾯按照步骤讲解⼀下。
环境依赖
安装pyinstaller。
pip install pyinstaller -i pypi.douban/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 is non existent
641 INFO: Initializing module
649 INFO: Caching module
696 INFO: Analyzing base_library.zip ...
4371 INFO: Caching module
4614 INFO: running
4619 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\yi\appdata\local\programs\python\
5046 INFO: Analyzing C:\Users\yi\PycharmProjects\txl\main.py
5049 INFO: Processing
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\
5765 INFO: Graph cross-reference written to C:\Users\yi\PycharmProjects\txl\build\main ref-main.html
5782 INFO: checking PYZ
饮水思源的意思5783 INFO: Building PYZ 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 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\
7803 INFO: checking EXE
7803 INFO: Building EXE is non existent
7804 INFO: Building EXE
7805 INFO: Copying bootloader EXE to C:\Users\yi\PycharmProjects\txl\
7897 INFO: Copying icon to EXE
2021小年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\
8007 INFO: Updating resource type 24 name 1 language 0
手抓饼怎么做8011 INFO: Appending PKG archive to EXE
9702 INFO: Building EXE completed successfully.
C:\Users\yi\PycharmProjects\txl>女生的手怎样变好看
会在dist⽣成exe⽂件,就是我们要的。
双击执⾏⼀下
总结
没啥总结的,做个记录。
到此这篇关于Python项⽬打包成exe⽂件的⽂章就介绍到这了,更多相关Python打包成exe⽂件内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论