follow my heart...
分类: Python/Ruby
2007-03-14 17:07:49
另类的方法,对语言特性都还不是100%支持,众多的模块也不可以使用,还有,我也没有试过:
在最后,给一个人学习py2exe的文章,帮助学习:
最近学了一点PYTHON,想把PYTHON写的程序转换成EXE文件,在网上查到了资料后发现了这个东东
写下来做一下记录。
英文教程:
Python 2.5 + Py2exe
工作目录:c:\python25
首先随便写一个程序
hello.py
print "Hello World!"
测试一下是否能运行
python hello.py
结果:Hello World
到下载 PY2exe ,或者在SF上下载
接下来直接安装PY2EXE包。。它是一个安装文件。。直接装就行了。
下在编写一个设置的PY文件 setup.py
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
运行:python setup.py py2exe
出现以下信息后,在DIST目录里,就会有一个hello.exe
即成功。
running py2exe
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'zlib'
creating python loader for extension 'unicodedata'
creating python loader for extension 'bz2'
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\bz2.py to bz2.pyc
byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\unicodedata.py to unicodedata.pyc
byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\zlib.py to zlib.pyc
skipping byte-compilation of c:\Python24\lib\StringIO.py to StringIO.pyc
[skipping many lines for brevity]
skipping byte-compilation of c:\Python24\lib\warnings.py to warnings.pyc
*** copy extensions ***
*** copy dlls ***
copying c:\Python24\lib\site-packages\py2exe\run.exe -> C:\Tutorial\dist\hello.exe
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
USER32.dll - C:\WINDOWS\system32\USER32.dll
SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll