py2exe,问题

时间:2010-07-30 19:57:53

标签: python windows-7 py2exe

我正在尝试将.py文件转换为.exe文件。但是,我得到一个奇怪的输出。

输出:

usage: module1 [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: module1 --help [cmd1 cmd2 ...]
   or: module1 --help-commands
   or: module1 cmd --help

error: no commands supplied

我的代码:

from distutils.core import setup
import py2exe

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

此操作完成后,我在哪里恢复.exe文件?我想将它放在闪存驱动器上进行重新分配。

我在Windows-7上运行Python 2.6,BTW

1 个答案:

答案 0 :(得分:1)

使用Gui2exe可以很聪明,我将它用于控制台和gui。

这是我使用的脚本,并且运行正常。

from distutils.core import setup
import py2exe
import sys

if len(sys.argv) == 1:
    sys.argv.append("py2exe")

setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 3}},
       zipfile = None,

       ## data_files = ['apple.jpg', 'cheese.jpg'],

       #Your py-file can use windows or console
       windows = [{"script": 'my.py'}])
相关问题