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

作者:挣扎的蓝藻 时间:2021-07-03 02:26:41 

首先需要安装pyinstaller库。


pip install pyinstaller

exe程序打包步骤

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

然后


pyinstaller -F hello.py

hello.py就是我要打包的文件。

常用参数:

-F 生成单个的exe文件。

-w 隐藏运行窗口。

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

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

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

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

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

将python文件打包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:\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

来源:https://blog.csdn.net/qq_38161040/article/details/89302030

标签:python,打包,exe
0
投稿

猜你喜欢

  • Python编程使用Selenium模拟淘宝登录实现过程

    2023-08-29 00:56:53
  • Python pyecharts绘制折线图详解

    2021-05-22 17:42:49
  • Python+Pygame实现彩色五子棋游戏

    2021-03-29 23:47:34
  • Python调用Windows API函数编写录音机和音乐播放器功能

    2021-06-13 19:03:55
  • 模仿MSN消息提示的效果

    2013-07-02 06:22:28
  • Python打印斐波拉契数列实例

    2022-11-03 11:40:41
  • python字符串的常用操作方法小结

    2023-11-29 03:01:37
  • MySQL数据库之UPDATE更新语句精解

    2009-03-20 15:21:00
  • Python生成短uuid的方法实例详解

    2021-06-30 14:12:03
  • CSS技巧之圆角背景与三角形

    2010-10-19 12:40:00
  • 微信小程序开发之获取用户手机号码(php接口解密)

    2023-11-15 03:34:59
  • Python实现简单的"导弹" 自动追踪原理解析

    2021-04-15 05:48:27
  • 基于Python实现自制拼图小游戏

    2021-12-01 03:25:01
  • JS将指定的某个字符全部转换为其他字符实例代码

    2023-08-28 21:01:01
  • Python提取Linux内核源代码的目录结构实现方法

    2023-03-05 11:29:49
  • python实现决策树分类算法

    2022-08-10 12:15:56
  • python math模块使用方法介绍

    2021-06-20 23:44:01
  • 图文教程教你asp编译成dll组件

    2010-07-16 13:16:00
  • Python 200行代码实现一个滑动验证码过程详解

    2022-08-24 18:24:35
  • Python小白学习爬虫常用请求报头

    2024-01-02 06:39:19
  • asp之家 网络编程 m.aspxhome.com