python - 当我运行一个非常简单的 py2exe 测试时,它给我错误

标签 python exe py2exe

<分区>

我编写了一个名为 test.py 的非常简单的程序,如下所示:

print 'hello world'

然后我编写了一个名为 setup.py 的安装程序,如下所示:

from distutils.core import setup
import py2exe

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

它们都在同一个文件夹中,所以它应该可以工作。当我运行 setup.py 时,它会给我如下所示的错误消息:

C:\Python26\lib\sets.py:85: DeprecationWarning: functions overriding warnings.showwarning() must support the 'line' argument
  stacklevel=2)
Traceback (most recent call last):
  File "C:\Users\python2.6\Desktop\program\pygametests\setup.py", line 5, in <module>
    setup(console=['test.py'])
  File "C:\Python26\lib\distutils\core.py", line 140, 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

我正在运行 windows vista。

最佳答案

您应该转到您的文件所在的文件夹并运行:

C:\Python27\mydir> python setup.py py2exe

或直接

C:\Python27\mydir> setup.py py2exe

回溯告诉您您没有在命令行中为 setup.py 发送任何命令(在我的示例中为“py2exe”)

您可以使用以下命令查看可用命令:

C:\Python27\mydir>setup.py --help-commands
Standard commands:
  build            build everything needed to install
  build_py         "build" pure Python modules (copy to build directory)
  build_ext        build C/C++ extensions (compile/link to build directory)
  build_clib       build C/C++ libraries used by Python extensions
  build_scripts    "build" scripts (copy and fixup #! line)
  clean            clean up temporary files from 'build' command
  install          install everything from build directory
  install_lib      install all Python modules (extensions and pure Python)
  install_headers  install C/C++ header files
  install_scripts  install scripts (Python or otherwise)
  install_data     install data files
  sdist            create a source distribution (tarball, zip file, etc.)
  register         register the distribution with the Python package index
  bdist            create a built (binary) distribution
  bdist_dumb       create a "dumb" built distribution
  bdist_rpm        create an RPM distribution
  bdist_wininst    create an executable installer for MS Windows
  upload           upload binary package to PyPI
  check            perform some checks on the package
  py2exe

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


C:\Python27\mydir>

关于python - 当我运行一个非常简单的 py2exe 测试时,它给我错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10937798/

相关文章:

python - "Find the longest substring with k-unique characters"的时间复杂度?

python - 在 Python 中从文件名中提取扩展名

python - python 2.7 的 Pandas 导入错误

python - 线性回归在 Python 中失败,因变量中的值很大

c# - 将 .exe 项目转换为类库

python - py2exe问题

windows - 如何手动编写和执行 Windows .exe(使用十六进制编辑器的机器代码)?

c++ - 更改已编译/压缩 EXE 的标题

python - 运行使用py2exe编译的可执行文件时出错