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

Win10+PyCharm环境下Python3.7.9安装py2exe报错求助

解决Windows 10 PyCharm中安装py2exe-3包的报错问题

问题场景

在Windows 10系统的PyCharm中,尝试从lambacck的py2exe-3 GitHub仓库安装py2exe包时,出现以下报错:

It seems that you are using distutils.command.build to add new subcommands. Using distutils directly is considered deprecated, please use setuptools.command.build.

      By 2023-Dec-13, you need to update your project and remove deprecated calls
      or your builds will no longer be supported.
    
      See https://peps.python.org/pep-0632/ for details.
      ********************************************************************************

!! missing_cmds = set(build.get_sub_commands()) - _ORIGINAL_SUBCOMMANDS error: 'ext_modules' option must be a list of Extension instances [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

Getting requirements to build wheel did not run successfully. exit code: 1

See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

修复方案

方案1:降级setuptools后安装

新版本setuptools对废弃的distutils限制严格,降级到兼容版本即可:

  • 执行命令降级setuptools:
    pip install setuptools==65.5.0
    
  • 再重新安装该仓库的包:
    pip install git+https://github.com/lambacck/py2exe-3.git
    

方案2:修改仓库代码后本地安装

如果需要使用该分支的特定功能,手动修改代码适配setuptools:

  • 将该仓库克隆到本地
  • 打开项目中的setup.py文件,把所有distutils.command.build的引用替换为setuptools.command.build
  • 检查ext_modules配置项,确保它是setuptools.Extension实例的列表,修正不符合的定义
  • 在本地项目目录执行安装命令:
    pip install .
    

方案3:改用官方维护的py2exe版本

该第三方分支未及时适配新规范,直接使用官方包更稳定:

pip install py2exe

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 23:35:06