Python怎样打包成exe?

分类:Python | 作者:凹凸曼 | 发表于2011/03/01 Python怎样打包成exe?已关闭评论

发现PyInstaller 是个不错的东东,解决打包单个exe的问题,使用非常简单,不用编写setup脚本:
进入开发目录,执行命令行(可以做个bat文件):
引用
python d:\pyinstaller-1.3\configure.py
python d:\pyinstaller-1.3\Makespec.py client.py –onefile –windowed –icon=client.ico
python d:\pyinstaller-1.3\build.py client.spec
就这样一个单独的client.exe就产生了,不到3M,是压缩前的三分之一,如果用wxpython大概会有6M多,py2exe压缩的单个exe也差不多这个大小,但py2exe并没有把所有的dll打包。pyinstaller打包比较彻底,就只有一个exe文件。
生成完后同时有个警告文件,内容是:
引用
W: no module named posix (conditional import by os)
W: no module named optik.__all__ (top-level import by optparse)
W: no module named pwd (delayed, conditional import by posixpath)
W: no module named MacOS (top-level import by Tkinter)
W: no module named posix (delayed, conditional import by iu)
W: no module named org (top-level import by copy)
W: no module named _emx_link (conditional import by os)
W: no module named optik.__version__ (top-level import by optparse)
W: __all__ is built strangely at line 0 – __future__ (C:\Python25\lib\__future__.pyc)
W: delayed  __import__ hack detected at line 0 – encodings (C:\Python25\lib\encodings\__init__.pyc)
W: delayed  exec statement detected at line 0 – Tkinter (C:\Python25\lib\lib-tk\Tkinter.pyc)
W: __all__ is built strangely at line 0 – optparse (d:\pyinstaller-1.3\optparse.pyc)
W: delayed  exec statement detected at line 0 – socket (C:\Python25\lib\socket.pyc)
W: delayed  eval hack detected at line 0 – os (C:\Python25\lib\os.pyc)
W: __all__ is built strangely at line 0 – tokenize (C:\Python25\lib\tokenize.pyc)
W: delayed conditional exec statement detected at line 0 – iu (d:\pyinstaller-1.3\iu.pyc)
W: delayed conditional exec statement detected at line 0 – iu (d:\pyinstaller-1.3\iu.pyc)
W: delayed  eval hack detected at line 0 – gettext (C:\Python25\lib\gettext.pyc)
W: delayed  __import__ hack detected at line 0 – optik.option_parser (d:\pyinstaller-1.3\optik\option_parser.pyc)
W: delayed conditional eval hack detected at line 0 – warnings (C:\Python25\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 – warnings (C:\Python25\lib\warnings.pyc)
W: __all__ is built strangely at line 0 – optik (d:\pyinstaller-1.3\optik\__init__.pyc)
不影响程序使用。

原文:http://jar-c.blog.163.com/blog/static/1164012502010911101823452/

日志信息 »

该日志于2011-03-01 01:22由 凹凸曼 发表在Python分类下, 评论已关闭。

目前盖楼

抱歉,评论被关闭

« »