简体   繁体   English

将python程序转换为Windows可执行文件

[英]convert python programme to windows executable

im trying to create windows executable from python program which has GUI . 我试图从具有GUI的python程序创建Windows可执行文件。 im using following script 我正在使用以下脚本

from distutils.core import setup
import py2exe

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

it gives following error 它给出了以下错误

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

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. 我无法理解为什么需要提供命令,因为它是基于GUI的应用程序,但它第一次工作正常,然后它给出了上述错误。 please help.......... 请帮忙..........

The problem is that you are compiling this script from the Python IDLE. 问题是您正在从Python IDLE编译此脚本。 This is not how it is done with py2exe . 这不是py2exe If you have used Disutils before, you might have seen this: 如果你之前使用过Disutils ,你可能已经看过:

python setup.py install . python setup.py install

And same is the case of py2exe , you run it from the command line and not the IDLE. 同样是py2exe的情况,你从命令行而不是IDLE运行它。 So open up cmd and then issue the command: 所以打开cmd ,然后发出命令:

python setup.py py2exe

Here setup.py is your script file. 这里setup.py是你的脚本文件。

This is better explained in the tutorial . 这在教程中有更好的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM