Windows下用py2exe将Python程序打包成exe程序的教程
2015-04-08 10:32
1026 查看
py2exe在sourceforge 的下载只支持到2.7。
针对python3.0+的版本,需要自己编译。
1.下载源码
svn checkout svn://svn.code.sf.net/p/py2exe/svn/trunk py2exe-svn
2.编译环境
这里使用的是vs2014.
3.安装
进入py2exe-3
python setup.py install
这里会进行编译、安装。
此外,python默认使用的是vs9,针对vs2014,需要改下文件:
复制代码 代码如下: Lib\distutils\msvc9compiler.py寻找:
复制代码 代码如下: VERSION = get_build_version()在下面增加:
复制代码 代码如下: VERSION = 11.0如果出现错误:
复制代码 代码如下: Failed to load and parse the manifest. The system cannot find the file specified.error: command 'mt.exe' failed with exit status 31
解决办法:由于vs2010后的link.exe的参数稍微有些改变,所以在link的时候没有生成manifest文件,自然mt.exe找不到这个文件。只需要在msvc9compiler.py里面搜索一下MANIFESTFILE,然后在他上面加一行 ld_args.append('/MANIFEST'),保存就OK了。(python3.4好像没有这个问题,2.7存在)
4.setup.py
setup.py可以参考官网,其中的参数--bundle-files,需要特别说下,想打成一个整包要设成0.
变化可以参考:http://sourceforge.net/p/py2exe/svn/HEAD/tree/trunk/py2exe-3/
最后附上setup.py
from distutils.core import setup import py2exe import sys,os if sys.version_info.major >= 3.0: opt_bundle_files = 0 else: opt_bundle_files = 1 includes = ["PyQt4.QtCore","PyQt4.QtGui","sip"] options = {"py2exe": { "compressed": 1, "optimize": 2, "includes": includes, "bundle_files": opt_bundle_files, } } setup( version = "0.1.0", description = "test_add", options = options, zipfile=None, console=[{"script": "test_add.py", "icon_resources": [(1, "py.ico")] }], #windows=[{"script": "test_add.py", "icon_resources": [(1, "py.ico")] }], )
您可能感兴趣的文章:
- Windows下将Python文件打包成.EXE可执行文件的方法
- 用node-webkit把web应用打包成桌面应用(windows环境)
- windows下定时利用bat脚本实现ftp上传下载
- Windows下简单的Mysql备份BAT脚本分享
- Windows下通过bat获取网络连线实际名称,加强IP类设置脚本的兼容性
- Windows命令行bat批处理延迟sleep方法(批处理延时)
- windows7系统去除快捷方式小箭头BAT脚本分享
- PHP启动windows应用程序、执行bat批处理、执行cmd命令的方法(exec、system函数详解)
- Windows运行bat批处理文件时隐藏cmd命令提示符窗口的方法
- Windows设置开机自启动bat脚本
- 一键删除windows默认共享和禁止空连接的bat代码
- Windows程序打包脚本[bat]的详细流程
相关文章推荐
- 使用py2exe打包python脚本为exe可执行程序
- 使用py2exe在Windows下将Python程序转为exe文件
- 通过Py2exe将自己的python程序打包成.exe/.app的方法
- 使用py2exe在Windows下将Python程序转为exe文件
- 使用 pyinstaller 把python脚本打包成 windows exe 可执行程序
- Windows中使用wxPython和py2exe开发Python的GUI程序的实例教程
- Py2exe——将python程序变成windows下可执行的exe
- python 程序打包成exe py2exe
- windows下使用cx_freeze将Python程序打包成exe可执行文件
- Windows 中使用py2exe将python程序打包成可执行程序
- windows7下使用py2exe把python打包程序为exe文件
- 使用py2exe来打包python脚本到exe程序
- windows下使用cx_freeze将Python程序打包成exe可执行文件
- PyInstaller(windows开发,打包python软件为exe)使用教程
- Windows中使用wxPython和py2exe开发Python的GUI程序的实例教程
- 如何利用Python2.7、py2exe、PyInstaller-2.1将*.py打包成*.exe,再利用Inno Setup Compiler封装成windows安装文件
- 【Python】使用 py2exe打包Python程序为.exe文件
- Python程序windows下打包成exe
- Qt程序打包成exe可执行文件图文教程
- windows环境,python打包命令行程序