前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python 技术篇-将python项目打包成exe独立运行程序,pyinstaller库打包python代码

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

作者头像
小蓝枣
发布2020-09-24 10:34:05
1.7K0
发布2020-09-24 10:34:05
举报

首先需要安装 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 就成功了。

代码语言:javascript
复制
96 INFO: PyInstaller: 3.4
96 INFO: Python: 3.6.8
97 INFO: Platform: Windows-7-6.1.7601-SP1
98 INFO: wrote D:\pyinstaller\hello.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.8\python.exe
5582 INFO: Caching module hooks...
5590 INFO: Analyzing D:\pyinstaller\hello.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.8\python36.dll
6288 INFO: Found binding redirects:
[]
6294 INFO: Warnings written to D:\pyinstaller\build\hello\warn-hello.txt
6349 INFO: Graph cross-reference written to D:\pyinstaller\build\hello\xref-hell
o.html
6357 INFO: checking PYZ
6358 INFO: Building PYZ because PYZ-00.toc is non existent
6359 INFO: Building PYZ (ZlibArchive) D:\pyinstaller\build\hello\PYZ-00.pyz
7000 INFO: Building PYZ (ZlibArchive) D:\pyinstaller\build\hello\PYZ-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.8\lib\site-packages\PyInstaller\bootloader\Wi
ndows-32bit\run.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:\pyinstaller\dist\hello.exe
8836 INFO: Building EXE from EXE-00.toc completed successfully.
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-04-14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • exe程序打包步骤
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档