失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Python 技术篇-将python项目打包成exe独立运行程序 pyinstaller库打包python代码实例演示

Python 技术篇-将python项目打包成exe独立运行程序 pyinstaller库打包python代码实例演示

时间:2022-05-06 07:52:35

相关推荐

Python 技术篇-将python项目打包成exe独立运行程序 pyinstaller库打包python代码实例演示

首先需要安装pyinstaller库。

pip install pyinstaller

就可以了。

exe程序打包步骤

cmd进入要编译的python文件所在的文件夹,

然后pyinstaller -F hello.py就好了,hello.py就是我要打包的文件。

常用参数

-F生成单个的exe文件。

-w隐藏运行窗口。

-h可以查看帮助信息,更多指令可以通过这个查看。

最开始D:\pyinstaller目录下只有hello.py这一个文件,其它的文件都是后生成的。

生成的exe文件在dist里,这个exe文件单独拿出来放在任何的位置都可以运行。

编译过程:

出现completed successfully就成功了。

96 INFO: PyInstaller: 3.496 INFO: Python: 3.6.897 INFO: Platform: Windows-7-6.1.7601-SP198 INFO: wrote D:\pyinstaller\hello.spec105 INFO: UPX is not available.107 INFO: Extending PYTHONPATH with paths['D:\\pyinstaller', 'D:\\pyinstaller']107 INFO: checking Analysis108 INFO: Building Analysis because Analysis-00.toc is non existent108 INFO: Initializing module dependency graph...110 INFO: Initializing module graph hooks...112 INFO: Analyzing base_library.zip ...4577 INFO: running Analysis Analysis-00.toc4582 INFO: Adding mon-Controls to dependent assemblies of final executablerequired by d:\python3.6.8\python.exe5582 INFO: Caching module hooks...5590 INFO: Analyzing D:\pyinstaller\hello.py5596 INFO: Loading module hooks...5597 INFO: Loading module hook "hook-encodings.py"...5845 INFO: Loading module hook "hook-pydoc.py"...5847 INFO: Loading module hook "hook-xml.py"...6152 INFO: Looking for ctypes DLLs6152 INFO: Analyzing run-time hooks ...6164 INFO: Looking for dynamic libraries6287 INFO: Looking for eggs6287 INFO: Using Python library d:\python3.6.8\python36.dll6288 INFO: Found binding redirects:[]6294 INFO: Warnings written to D:\pyinstaller\build\hello\warn-hello.txt6349 INFO: Graph cross-reference written to D:\pyinstaller\build\hello\xref-hello.html6357 INFO: checking PYZ6358 INFO: Building PYZ because PYZ-00.toc is non existent6359 INFO: Building PYZ (ZlibArchive) D:\pyinstaller\build\hello\PYZ-00.pyz7000 INFO: Building PYZ (ZlibArchive) D:\pyinstaller\build\hello\PYZ-00.pyz completed successfully.7006 INFO: checking PKG7007 INFO: Building PKG because PKG-00.toc is non existent7007 INFO: Building PKG (CArchive) PKG-00.pkg8818 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.8822 INFO: Bootloader d:\python3.6.8\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe8822 INFO: checking EXE8823 INFO: Building EXE because EXE-00.toc is non existent8824 INFO: Building EXE from EXE-00.toc8826 INFO: Appending archive to EXE D:\pyinstaller\dist\hello.exe8836 INFO: Building EXE from EXE-00.toc completed successfully.

喜欢的点个赞❤吧!

如果觉得《Python 技术篇-将python项目打包成exe独立运行程序 pyinstaller库打包python代码实例演示》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。