Hi!请登陆

把python脚本编译成exe

2020-10-31 60 10/31

目前有三种方法

[TOC]

pyinstaller

下载地址

最近更新时间2013-09-28
官网:http://www.pyinstaller.org/
github: https://github.com/pyinstaller/pyinstaller

支持版本

2.4 - 2.7

使用方法

python pyinstaller.py [opts] yourprogram.py
主要选项包括:

-F, –onefile 打包成一个exe文件。
-D, –onedir 创建一个目录,包含exe文件,但会依赖很多文件(默认选项)。
-c, –console, –nowindowed 使用控制台,无界面(默认)
-w, –windowed, –noconsole 使用窗口,无控制台

py2exe

下载地址

最近更新时间2008-11-16
官网:http://www.py2exe.org/

支持版本

使用方法

  1. 新建一个setup.py,内容如下(target.py就是你将要编译的文件)

    from distutils.core import setup
    import py2exe
    setup(console=["target.py"])

  2. 执行python setup.py py2exe
  3. dist文件夹里就是你需要的exe

帮助命令 python setup.py py2exe --help

cx_Freeze

下载地址

最近更新时间2014-05-04
官网:http://sourceforge.net/projects/cx-freeze/

支持版本

2.4-2.7

使用方法

查看帮助:cxfreeze -h

打包命令 cxfreeze target.py --target-dir dist

帮助文档:http://cx-freeze.readthedocs.org/en/latest/index.html

相关推荐