pyinstaller:py文件转exe入门

1.先下载pyinstaller,可直接利用pip命令进行下载:pip install pyinstaller
另附pyinstaller官网地址http://www.pyinstaller.org/downloads.html

2.下载安装pyinstaler运行时所需要的windows扩展pywin32,https://github.com/mhammond/pywin32/releases

3.为了后续使用方便,可以把pyinstaller的安装目录设为环境变量,这样就可以在项目路径下进入cmd实现打包。

4.项目编写完成之后,在工程目录下进入命令行窗口,输入 pyinstaller -F xxxx.py即可转换为exe。其中xxx.py需为主函数。

D:\python\check_dex>pyinstaller -F get_dex_count.py
116 INFO: PyInstaller: 3.6
116 INFO: Python: 3.7.4
117 INFO: Platform: Windows-10-10.0.18362-SP0
119 INFO: wrote D:\python\check_dex\get_dex_count.spec
122 INFO: UPX is not available.
124 INFO: Extending PYTHONPATH with paths
['D:\\python\\check_dex', 'D:\\python\\check_dex']
124 INFO: checking Analysis
129 INFO: Building Analysis because Analysis-00.toc is non existent
129 INFO: Initializing module dependency graph...
131 INFO: Caching module graph hooks...
141 INFO: Analyzing base_library.zip ...
2965 INFO: Caching module dependency graph...
3104 INFO: running Analysis Analysis-00.toc
3110 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by d:\pycharmproject\check_dex\scripts\python.exe
3132 INFO: Analyzing D:\python\check_dex\get_dex_count.py
3137 INFO: Processing module hooks...
3138 INFO: Loading module hook "hook-encodings.py"...
3265 INFO: Loading module hook "hook-pydoc.py"...
3269 INFO: Loading module hook "hook-xml.py"...
3462 INFO: Looking for ctypes DLLs
3462 INFO: Analyzing run-time hooks ...
3470 INFO: Looking for dynamic libraries
3968 INFO: Looking for eggs
3968 INFO: Using Python library E:\python\python37.dll
3971 INFO: Found binding redirects:
[]
3974 INFO: Warnings written to D:\python\check_dex\build\get_dex_count\warn-get_dex_count.txt
4001 INFO: Graph cross-reference written to D:\python\check_dex\build\get_dex_count\xref-get_dex_count.html
4009 INFO: checking PYZ
4009 INFO: Building PYZ because PYZ-00.toc is non existent
4009 INFO: Building PYZ (ZlibArchive) D:\python\check_dex\build\get_dex_count\PYZ-00.pyz
4395 INFO: Building PYZ (ZlibArchive) D:\python\check_dex\build\get_dex_count\PYZ-00.pyz completed successfully.
4401 INFO: checking PKG
4401 INFO: Building PKG because PKG-00.toc is non existent
4405 INFO: Building PKG (CArchive) PKG-00.pkg
5872 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
5879 INFO: Bootloader d:\pycharmproject\check_dex\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
5879 INFO: checking EXE
5879 INFO: Building EXE because EXE-00.toc is non existent
5879 INFO: Building EXE from EXE-00.toc
5880 INFO: Appending archive to EXE D:\python\check_dex\dist\get_dex_count.exe
5889 INFO: Building EXE from EXE-00.toc completed successfully.

参数使用:

-F 或 --onefile :指定打包后只生成一个exe格式的文件(建议写上这个参数)

-D –onedir :创建一个目录,包含exe文件,但会依赖很多文件(默认选项)

-c –console, –nowindowed 使用控制台,无界面(默认)

-w –windowed, –noconsole 使用窗口,无控制台

-p 添加搜索路径,让其找到对应的库。

-i 改变生成程序的icon图标

最后,打包后的exe文件在dist目录下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值