2012-06-07 74 views
4

我寫了一個名爲test.py一個非常簡單的程序,它看起來像這樣:當我運行一個非常簡單的py2exe測試,它給我的錯誤

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。

+0

我相信setup.py是某種類型的系統命令或生活在路徑中。嘗試將您的文件的名稱從setup.py更改爲mySetup.py或類似的東西。 – NKamrath

回答

3

你應該去的地方,你有你的文件並運行該文件夾:

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

或直接

C:\Python27\mydir> setup.py py2exe 

回溯告訴你,你是不是在發送任何指令(「py2exe」我的例子)在命令行中輸入setup.py

可以看到可用的命令:

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> 
+0

我一直在從文件本身直接運行程序,現在當我轉到cmd中的文件夾時,它告訴我python不被識別爲內部或外部命令,可操作程序或批處理文件。 – Chachmu

+0

哇...這很好,感謝所有的幫助! – Chachmu

+0

@ user1429351這是因爲在Windows上,Python不會自動添加到PATH變量中。你需要通過R-單擊我的電腦 - >屬性 - >高級系統設置 - >環境變量 - >在列表中找到「PATH」來設置它,並將你的Python文件夾添加到字符串中,單擊確定並打開一個新的CLI並再次嘗試。 –

相關問題