ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2019-06-30 04:55:11  阅读:188  来源: 互联网

标签:python exe py2exe


参见英文答案 > convert python programme to windows executable                                    1个
我写了一个名为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,exe,py2exe
来源: https://codeday.me/bug/20190630/1333276.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有