原来可以在没安装 python 环境的 windows 上,用 pyinstaller 生成一个 py 对应的 exe,运行这个 py 程序。附 pyinstaller 编译脚本

今天才知道,原来可以在没安装 python 环境的 windows 上,用 pyinstaller 生成一个 py 对应的 exe,双击它来运行 py 程序。

 

pyInstaller 的下载页:  http://www.pyinstaller.org/downloads.html

 

编译方法:

在 cmd 里,进入 d:\pyStuff\PyInstaller-3.5 文件夹,运行:

python pyinstaller.py -F -w D:\workspace\configFile.py

 

参数说明:

-F, --onefile    py 代码只有一个文件
-D, --onedir    py 代码放在一个目录中(默认是这个)

-w, --windowed       exe 运行时没有 console
-c, --nowindowed    exe 运行时有 console (默认是这个)

 

pyinstaller 编译 exe 的脚本:

新建一个 .bat 文件,写以下内容。双击这个 bat 文件,就能编译出来 exe 了。

编译结果在 d:\pyStuff\PyInstaller-3.5\GetArgs\dist 里。

@echo off

d:

cd d:\pyStuff\PyInstaller-3.5

python pyinstaller.py -F -w D:\workspace\pyTest\GetArgs.py

 

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值