我正在尝试从.py文件创建可执行文件。
我这样做了:
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运行。它返回以下错误:
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
我在Windows 8.1和cx_Freeze-4.3.2.win32-py3.2上使用Python 3.2
感谢您的帮助!
答案 0 :(得分:0)
您需要实际将命令传递给sample_scv_1.csv
以告诉它构建可执行文件
setup.py
此命令将创建一个名为
python setup.py build
的子目录,其子目录以字母build
开头,以distutils使用的平台的典型标识符结束
或者,您可以让它构建可执行文件并将其包装在安装程序中以便于分发
exe.
答案 1 :(得分:0)
如果您不想通过命令行提供命令,则可以让脚本为您执行。
将此代码放在UIScreen.main.nativeBounds
之前的代码中,您可以运行它而无需自己添加参数:
cx_Freeze.setup
这与像这样运行文件相同:
import sys
sys.argv.append("build")