Python 3.2.2,错误(脚本转exe)

2 投票
1 回答
1086 浏览
提问于 2025-04-17 15:32

你好,我按照这个说明(如何使用py2exe将python3.2的代码转换为exe)来把我的Python脚本(版本3.2.2)变成exe文件,但出现了一个错误:

Traceback (most recent call last):
  File "C:\Python32\Scripts\setup.py", line 7, in <module>
    executables = [Executable("ochranka.py")])
  File "C:\Python32\lib\site-packages\cx_Freeze\dist.py", line 365, in setup
    distutils.core.setup(**attrs)
  File "C:\Python32\lib\distutils\core.py", line 136, in setup
    raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
SystemExit: 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

这是我的setup.py文件:

from cx_Freeze import setup, Executable
setup(
    name = "Ochranka",
    version = "1.0",
    description = "test",
    executables = [Executable("ochranka.py")])

我还是个新手,不知道该怎么处理这个问题。

1 个回答

5

你需要给 setup.py 传递一个命令;在这个情况下,就是 build*:

python setup.py build

我敢打赌你忘记了 build 这个部分。

*注意:我不太确定 build 是你想要的命令(因为我已经有一段时间没用过 cx_freeze 了)。可以查看 文档

撰写回答