简要
pyinstaller模块主要用于python代码打包成exe程序直接使用,这样在其它电脑上即使没有python环境也是可以运行的。
用法
一.安装
pyinstaller属于第三方库,因此在使用的时候需提前安装
pip install pyinstaller
二.配置spec文件
1.配置生成exe程序文件夹
(1)如果不熟悉spec配置内容,可以在终端运行如下指令生成固定模板
pyinstaller --name myapp main.py # myapp为生成的spec文件名称,main.py为打包的文件
(2)运行完后我们会看见如下几个文件,dist和build直接删除即可。我看打开myapp.spec文件可以看见配置信息。
# -*- mode: python ; coding: utf-8 -*- block_cipher = None a = Analysis( ['main.py','hello.py'], 注:要打包的模块,按照先后顺序运行 pathex=['C