Py2exe错误:没有提供命令

时间:2015-07-25 20:26:35

标签: python py2exe setup.py

我正在尝试使用Py2exe库将我的Python程序转换为下面的setup.py代码:

    from distutils.core import setup
    import py2exe

    file = raw_input("Python file to convert:")

    setup(console=[file]) 

然后,当我输入我要转换的程序时,它会说:

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

    error: no commands supplied

然后停止。你们中的任何人都知道造成这种情况的原因吗?

2 个答案:

答案 0 :(得分:2)

你可以尝试

python setup.py install

答案 1 :(得分:0)

我遇到了与原始海报相同的错误。 即使在玩具hello世界风格的脚本上,我也无法使py2exe工作。 然而: 这对我有用:PyInstaller,更多说明在这里: How to make a Python script standalone executable to run without ANY dependency?

如果需要参数,则应采用以下形式: 将其放在python脚本中:

import sys
thisArg = sys.argv[1]

确保在命令提示符中使用以下参数调用它:

my_script“ argument1”

注意,结尾没有.py。

argv [0]是self,脚本名称本身。