Python怎样打包成exe

全屏阅读
  • 基本信息
  • 作者:
  • 作者已发布:928篇文章
  • 发布时间:2023年08月13日 11:23:58
  • 所属分类:python3
  • 阅读次数:205次阅读
  • 标签:

发现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)
不影响程序使用。

顶一下
(0)
100%
订阅 回复
踩一下
(0)
100%
» 郑重声明:本文由mpxq168发布,所有内容仅代表个人观点。版权归恒富网mpxq168共有,欢迎转载, 但未经作者同意必须保留此段声明,并给出文章连接,否则保留追究法律责任的权利! 如果本文侵犯了您的权益,请留言。

目前有 0 条留言 其中:访客:0 条, 博主:0 条

给我留言

您必须 [ 登录 ] 才能发表留言!