将python程序转换为windows可执行文件 [英] convert python programme to windows executable

查看:57
本文介绍了将python程序转换为windows可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从具有 GUI 的 python 程序创建 Windows 可执行文件.我正在使用以下脚本

i m trying to create windows executable from python program which has GUI . i m using following script

from distutils.core import setup
import py2exe

setup(console=['gui.py']) 

出现以下错误

Warning (from warnings module):
  File "C:\Python27\lib\distutils\dist.py", line 267
    warnings.warn(msg)
UserWarning: Unknown distribution option: 'console'

Traceback (most recent call last):
  File "E:\my python\py2exe.py", line 3, in <module>
    import py2exe
  File "E:\my python\py2exe.py", line 5, in <module>
    setup(console=['ASUP_finalDone1.py'])
  File "C:\Python27\lib\distutils\core.py", line 140, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: py2exe.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: py2exe.py --help [cmd1 cmd2 ...]
   or: py2exe.py --help-commands
   or: py2exe.py cmd --help

error: no commands supplied

我不明白为什么需要提供命令,因为它是基于 GUI 的应用程序,但它第一次运行良好,然后出现上述错误.请帮忙.......

i can't understand why to need for supplying command as it is GUI based application but it worked fine first time and then it gives above error. please help..........

推荐答案

问题是您正在从 Python IDLE 编译此脚本.这不是使用 py2exe 完成的.如果您之前使用过 Disutils,您可能已经看到了:

The problem is that you are compiling this script from the Python IDLE. This is not how it is done with py2exe. If you have used Disutils before, you might have seen this:

python setup.py install.

py2exe 也是如此,您可以从命令行而不是 IDLE 运行它.所以打开cmd,然后发出命令:

And same is the case of py2exe, you run it from the command line and not the IDLE. So open up cmd and then issue the command:

python setup.py py2exe

这里 setup.py 是你的脚本文件.

Here setup.py is your script file.

这在教程中有更好的解释.

这篇关于将python程序转换为windows可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆