栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

将python文件打包exe独立运行程序方法详解

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

将python文件打包exe独立运行程序方法详解

首先需要安装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.4
96 INFO: Python: 3.6.8
97 INFO: Platform: Windows-7-6.1.7601-SP1
98 INFO: wrote D:pyinstallerhello.spec
105 INFO: UPX is not available.
107 INFO: Extending PYTHonPATH with paths
['D:\pyinstaller', 'D:\pyinstaller']
107 INFO: checking Analysis
108 INFO: Building Analysis because Analysis-00.toc is non existent
108 INFO: Initializing module dependency graph...
110 INFO: Initializing module graph hooks...
112 INFO: Analyzing base_library.zip ...
4577 INFO: running Analysis Analysis-00.toc
4582 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of f
inal executable
 required by d:python3.6.8python.exe
5582 INFO: Caching module hooks...
5590 INFO: Analyzing D:pyinstallerhello.py
5596 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 DLLs
6152 INFO: Analyzing run-time hooks ...
6164 INFO: Looking for dynamic libraries
6287 INFO: Looking for eggs
6287 INFO: Using Python library d:python3.6.8python36.dll
6288 INFO: Found binding redirects:
[]
6294 INFO: Warnings written to D:pyinstallerbuildhellowarn-hello.txt
6349 INFO: Graph cross-reference written to D:pyinstallerbuildhelloxref-hell
o.html
6357 INFO: checking PYZ
6358 INFO: Building PYZ because PYZ-00.toc is non existent
6359 INFO: Building PYZ (ZlibArchive) D:pyinstallerbuildhelloPYZ-00.pyz
7000 INFO: Building PYZ (ZlibArchive) D:pyinstallerbuildhelloPYZ-00.pyz comp
leted successfully.
7006 INFO: checking PKG
7007 INFO: Building PKG because PKG-00.toc is non existent
7007 INFO: Building PKG (CArchive) PKG-00.pkg
8818 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
8822 INFO: Bootloader d:python3.6.8libsite-packagesPyInstallerbootloaderWi
ndows-32bitrun.exe
8822 INFO: checking EXE
8823 INFO: Building EXE because EXE-00.toc is non existent
8824 INFO: Building EXE from EXE-00.toc
8826 INFO: Appending archive to EXE D:pyinstallerdisthello.exe

更多关于将python文件打包exe独立运行程序方法请查看下面的相关链接

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/21503.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号