You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用cx_Freeze将.py转exe报错:no commands supplied

解决cx_Freeze打包时的"no commands supplied"错误

我尝试用cx_Freeze将calculator.py转换为可执行文件,编写的setup.py代码如下:

from cx_Freeze import setup, Executable
 
buildOptions = dict(packages=['matplotlib', 'pandas', 'tkinter', 'numpy', 'math', 'sympy'])

exe = [Executable('calculator.py')]

setup(
    name='load impedance calculator',
    version='0.0.1',
    author='me',
    description = 'description',
    options = dict(build_exe = buildOptions),
    executables = exe
)

直接在Python GUI中运行该代码后,出现以下错误:

DistutilsArgError: no commands supplied

During handling of the above exception, another exception occurred:

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

解决步骤

  • 不要直接在Python GUI环境中运行setup.py文件,cx_Freeze需要通过命令行参数指定打包指令
  • 打开终端工具(Windows用命令提示符/PowerShell,macOS/Linux用终端),切换到setup.py所在的文件目录
  • 执行对应打包命令:
    • 生成包含可执行文件的文件夹:python setup.py build
    • 生成Windows安装包(.msi格式):python setup.py bdist_msi
    • 生成macOS应用包:python setup.py bdist_mac
    • 生成Linux可执行包:python setup.py bdist_linux

额外注意

  • 确保matplotlib、pandas等依赖包已提前正确安装,cx_Freeze会自动处理这些依赖的打包
  • Python 3.11与cx_Freeze 6.15.9版本兼容,无需调整版本

内容的提问来源于stack exchange,提问作者JayHuh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 04:47:39