用py2exe 创建可执行文件
来源:互联网 发布:linux 压缩与解压 编辑:程序博客网 时间:2024/05/16 14:49
py2exe是一种python发布工具,可以把python脚本转换成windows下的可执行程序,不需要安装python便可运行。py2exe现在可以用来创建使用了wxPython, Tkinter, Pmw,PyGTK, pygame, win32com client and server 等模块的程序。
详细介绍可以看它的官方网站 http://www.py2exe.org/
py2exe目前的版本是0.6.9,根据你安装的python的版本选择下载的文件
http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/
下载后,直接运行安装就行了,安装后的文件应该在你的python安装目录下的Lib\site-packages\py2exe
我们先准备一个简单的python程序hello.py
# hello.pydef main(): print "Hello, World!"if __name__ == '__main__': main()
然后为使用py2exe写一个脚本setup.py
# setup.pyfrom distutils.core import setupimport py2exe setup(console=["hello.py"])
运行setup.py,记得要传一个参数给它
python setup.py py2exe
应该看到一些输出信息
creating E:\Projects\WorkSpace\Python\buildcreating E:\Projects\WorkSpace\Python\build\bdist.win32creating E:\Projects\WorkSpace\Python\build\bdist.win32\winexecreating E:\Projects\WorkSpace\Python\build\bdist.win32\winexe\collectcreating E:\Projects\WorkSpace\Python\build\bdist.win32\winexe\tempcreating E:\Projects\WorkSpace\Python\dist*** searching for required modules ****** parsing results ***creating python loader for extension '_sre'*** finding dlls needed ****** create binaries ****** byte compile python files ***byte-compiling C:\Python23\lib\copy_reg.py to copy_reg.pycbyte-compiling C:\Python23\lib\sre_compile.py to sre_compile.pycbyte-compiling E:\Projects\WorkSpace\Python\build\bdist.win32\winexe\temp\_sre.py to _sre.pycbyte-compiling C:\Python23\lib\macpath.py to macpath.pycbyte-compiling C:\Python23\lib\popen2.py to popen2.pycbyte-compiling C:\Python23\lib\atexit.py to atexit.pycbyte-compiling C:\Python23\lib\os2emxpath.py to os2emxpath.pycbyte-compiling C:\Python23\lib\sre_constants.py to sre_constants.pycbyte-compiling C:\Python23\lib\re.py to re.pycbyte-compiling C:\Python23\lib\ntpath.py to ntpath.pycbyte-compiling C:\Python23\lib\stat.py to stat.pycbyte-compiling C:\Python23\lib\string.py to string.pycbyte-compiling C:\Python23\lib\warnings.py to warnings.pycbyte-compiling C:\Python23\lib\UserDict.py to UserDict.pycbyte-compiling C:\Python23\lib\repr.py to repr.pycbyte-compiling C:\Python23\lib\copy.py to copy.pycbyte-compiling C:\Python23\lib\types.py to types.pycbyte-compiling C:\Python23\lib\posixpath.py to posixpath.pycbyte-compiling C:\Python23\lib\sre.py to sre.pycbyte-compiling C:\Python23\lib\linecache.py to linecache.pycbyte-compiling C:\Python23\lib\sre_parse.py to sre_parse.pycbyte-compiling C:\Python23\lib\os.py to os.pyc*** copy extensions ***copying C:\Python23\DLLs\_sre.pyd ->; E:\Projects\WorkSpace\Python\dist*** copy dlls ***
py2exe会在当前目录下生成两个目录 build和dist
build里是一些py2exe运行时产生的中间文件,dist里有最终的可执行文件
library.zip python27.dll hello.exe
现在可以运行hello.exe了
E:\Projects\WorkSpace\Python\dist>helloHello, World!
python setup.py py2exe –help
看看py2exe都有哪些参数
- 用py2exe 创建可执行文件
- Python py2exe 创建可执行文件
- 使用py2exe生成可执行文件
- py2exe生成可执行文件
- py2exe:python,wxpython转exe可执行文件
- python中用py2exe打包可执行文件的参数设置
- 使用py2exe将python 脚本生成exe可执行文件
- py2exe
- py2exe
- py2exe
- py2exe
- py2exe
- py2exe
- py2exe
- Py2exe
- py2exe
- jar创建可执行文件
- vim创建可执行文件配置
- linux下vi命令大全
- Renesas SH-4 Calling Sequence Specification (Windows Embedded CE 6.0)
- Wireshark基本介绍和学习TCP三次握手
- Linux tr命令详解
- 在非ARC工程中加入ARC代码文件的方法
- 用py2exe 创建可执行文件
- json和XML的比较
- HDOJ P1004 Let the Balloon Rise
- su root 和su - root 的区别
- 递归方法建立树形目录
- Java中finalize()用法
- MXML
- 手动注册msxml4.dll
- C#字符串去除html标记