2016-10-07 64 views
0

我試圖從我的.py文件創建一個可執行文件。cx_Freeze錯誤:沒有提供命令

我這樣做:

import cx_Freeze 

executables = [cx_Freeze.Executable("Cobra.py")] 

cx_Freeze.setup(name="Snake Python", options={"build_exe":{"packages":["pygame","time","sys","os","random"]}}, executables = executables) 

而且從Python的GUI運行。它返回後續誤差修改:在Windows 8.1和cx_Freeze-4.3.2.win32-py3.2

Traceback (most recent call last): 
    File "C:/Users/victor/Desktop/tcc/Jogo_Cobra/setup.py", line 5, in <module> 
    cx_Freeze.setup(name="Snake Python", options={"build_exe":{"packages":["pygame","time","sys","os","random"]}}, executables = executables) 
    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 137, 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 supplies 
我使用Python 3.2

感謝您的幫助!

回答

0

實際上你需要通過一個命令setup.py告訴它生成可執行

python setup.py build 

This command will create a subdirectory called build with a further subdirectory starting with the letters exe. and ending with the typical identifier for the platform that distutils uses

或者你可以把它生成可執行文件並把它包裝在一個安裝容易分佈

python setup.py bdist_msi 
相關問題