使用py2exe生成独立的exe文件
来源:互联网 发布:yolo算法 编辑:程序博客网 时间:2024/05/05 01:43
今天写一个python小脚本,在windows下将当前状态下,所有的task的名字输出到一个文件里,然后将这个脚本转化成exe文件。
先看一下python脚本TaskNameList.py:
- import
subprocess -
- #
running the command "tasklist" in cmd.exe - popen
= subprocess.Popen("tasklist",stdout=subprocess.PIPE,shell= True) - namelist
= [] -
- #
get the task name - for
line inpopen.stdout.readlines()[ 3:]: -
name = line.split()[0] -
if name notin namelist: -
namelist.append(name) -
- popen.stdout.close()
-
- #
wirte the name into the file TaskNameList - file
= open(r".\TaskNameList.txt",'w') - file.writelines('\n'.join(namelist))
- file.close()
接下来我用了第三方的软件py2exe,将python脚本软化为exe可执行文件,在看完了py2exe官网上的tutorial后,写一个setup.py脚本
- from
distutils.core importsetup - import
py2exe -
- setup(console=["'TaskNameList.py"])
在查阅了资料后,我重写了一setup.py方法:
- from
distutils.core importsetup - import
py2exe - import
sys - includes
= ["encodings", "encodings.*"] - sys.argv.append("py2exe")
- options
= {"py2exe": { 1 } -
} - setup(options
= options, -
zipfile=None, -
console = [{"script":'TaskNameList.py'}])
这次直接执行python setup.py,就可以生成一个独立的exe文件了,当然这个文件还是在dist文件夹下。
这个文件比之前那个的最重要的改进在于两个参数:
- "bundle_files":
1
3 (default)
don't bundle
2
bundle everything but the Python interpreter
1
bundle everything, including the Python interpreter
- zipfile=None,
zipfile = None指定把library.zip也打包进exe 里了。
附:
- from
distutils.core importsetup - import
py2exe - import
sys - includes
= ["encodings", "encodings.*"] - sys.argv.append("py2exe")
- options
= {"py2exe": { 1 } -
} - setup(options
= options, -
zipfile=None, -
console = [{"script":'TaskNameList.py', 'icon_resources':[(1, 'logo.ico')]}])
- 使用py2exe生成独立的exe文件
- 使用py2exe生成独立的exe文件
- 使用py2exe生成独立的exe文件
- 使用py2exe生成独立的exe文件
- 使用py2exe生成独立的exe文件
- 使用py2exe生成一个exe文件
- 使用py2exe对Python文件进行封装生成exe文件
- python直接生成exe的方法(使用py2exe)
- python直接生成exe的方法(使用py2exe)
- python直接生成exe的方法(使用py2exe)
- 使用了Py2exe编译单个exe文件
- Python生成Exe:Py2exe
- 生成独立于CB的exe文件--c++bulider
- python GUI编程 glade+GTK+py2exe 生成exe文件
- 关于python中将py文件转换成exe文件的问题(使用py2exe)
- 使用py2exe将python 脚本生成exe可执行文件
- py2exe将py生成exe
- 使用Py2exe将PyQt程序打包为exe文件
- iOS_UITabBarController 标签视图控制器
- 理解GDT全局描述符的作用
- solrcoloud
- nginx配置:登录使用https
- 平衡堆+贪心 hdu1588 合并果子
- 使用py2exe生成独立的exe文件
- JAVA类集
- HDOJ 1004 C语言版
- UNIX网络编程笔记(5):处理SIGCHLD信号
- 趣学Python-教孩子学编程--第十一章
- 《Go语言入门》第一个Go语言Web程序——简单的Web服务器
- Quartz实现定时任务
- 从2-3-4树谈到Red-Black Tree(红黑树) http://www.cnblogs.com/guoyiqi/archive/2011/06/08/2129310.html
- Mysql5.7.9解压版下载、安装及修改密码(win7)