码迷,mamicode.com
首页 > 其他好文 > 详细

.py转.exe

时间:2021-06-24 18:10:33      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:ges   controls   loading   red   ini   ros   man   ati   upx   

https://blog.csdn.net/Nire_Yeyu/article/details/104683888/

安装:pip install pyinstaller

安装时报错,原因是环境变量需要在多配一个路径

技术图片

 

 

技术图片

 

 

打包为exe,版本尽量选择python3.6+32位版本,因为win64位系统向下兼容32位程序,但如果不考虑32位系统的话就无所谓,直接python64位版本直接打包即可,只是只能在win64位系统上跑

pyinstaller的打包机制:我们写的python脚本是不能脱离python解释器单独运行的,所以在打包时,至少会将python解释器和脚本一起打包,同样,为了打包的exe能正常运行,会把我们所有安装的第三方包一并打包到exe;即使我们项目只使用一个requests包,但可能还安装了其它n个包,但是他不管,因为包和包有依赖关系,如果我们只装了一个requests包,但requests包会顺带装一些其它依赖小包,所以为了安全,只能将所有三方包+python解释器一起打包。如下图所示

技术图片

 

 技术图片

 

 打包成功的信息如下:

D:\pylx\20210622>pyinstaller -F plcjwj.py
71 INFO: PyInstaller: 3.3.1
71 INFO: Python: 3.6.2
72 INFO: Platform: Windows-10-10.0.18362-SP0
74 INFO: wrote D:\pylx\20210622\plcjwj.spec
76 INFO: UPX is not available.
78 INFO: Extending PYTHONPATH with paths
[‘D:\\pylx\\20210622‘, ‘D:\\pylx\\20210622‘]
78 INFO: checking Analysis
81 INFO: Building because D:\pylx\20210622\plcjwj.py changed
81 INFO: Initializing module dependency graph...
84 INFO: Initializing module graph hooks...
86 INFO: Analyzing base_library.zip ...
3620 INFO: running Analysis out00-Analysis.toc
3623 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by d:\users\zr\appdata\local\programs\python\python36\python.exe
3879 INFO: Caching module hooks...
3884 INFO: Analyzing D:\pylx\20210622\plcjwj.py
3889 INFO: Loading module hooks...
3889 INFO: Loading module hook "hook-encodings.py"...
3996 INFO: Loading module hook "hook-pydoc.py"...
3997 INFO: Loading module hook "hook-xml.py"...
4299 INFO: Looking for ctypes DLLs
4299 INFO: Analyzing run-time hooks ...
4307 INFO: Looking for dynamic libraries
4384 INFO: Looking for eggs
4384 INFO: Using Python library d:\users\zr\appdata\local\programs\python\python36\python36.dll
4384 INFO: Found binding redirects:
[]
4392 INFO: Warnings written to D:\pylx\20210622\build\plcjwj\warnplcjwj.txt
4441 INFO: Graph cross-reference written to D:\pylx\20210622\build\plcjwj\xref-plcjwj.html
4454 INFO: checking PYZ
4456 INFO: Building because toc changed
4456 INFO: Building PYZ (ZlibArchive) D:\pylx\20210622\build\plcjwj\out00-PYZ.pyz
4997 INFO: Building PYZ (ZlibArchive) D:\pylx\20210622\build\plcjwj\out00-PYZ.pyz completed successfully.
5005 INFO: checking PKG
5006 INFO: Building because toc changed
5006 INFO: Building PKG (CArchive) out00-PKG.pkg
5077 INFO: Updating manifest in C:\Users\zr\AppData\Roaming\pyinstaller\bincache00_py36_64bit\unicodedata.pyd
5077 INFO: Updating resource type 24 name 2 language 1033
6561 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
6565 INFO: Bootloader d:\users\zr\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
6565 INFO: checking EXE
6567 INFO: Rebuilding out00-EXE.toc because plcjwj.exe missing
6567 INFO: Building EXE from out00-EXE.toc
6567 INFO: Appending archive to EXE D:\pylx\20210622\dist\plcjwj.exe
6578 INFO: Building EXE from out00-EXE.toc completed successfully.

技术图片

 

 

 

技术图片

 

 技术图片

 

 技术图片

 

 技术图片

 

 

pyinstaller -w -F XXX.py

-F是覆盖之前的打包

在.py转.exe过程中遇到了一个问题,

原因是:https://blog.csdn.net/weixin_41010198/article/details/87255393

这是因为您enum不是标准的库enum模块。您可能已enum34安装该软件包。
检查是否属于这种情况的一种方法是检查财产 enum.file

从python 3.6开始,enum34库不再与标准库兼容。该库也是不必要的,因此您只需卸载它即可。
我安装的python版本是3.6.5版本的,所有直接卸载enum库即可

技术图片

 

.py转.exe

标签:ges   controls   loading   red   ini   ros   man   ati   upx   

原文地址:https://www.cnblogs.com/ruijie/p/14926139.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!