ModuleNotFoundError: No module named 'distutils' 问题解决

884 阅读1分钟

解决方案:

  1. 安装 setuptools ,执行shell:pip install setuptools
  2. 或者升级已有的 setuptools ,执行shell:pip install --upgrade setuptools

macOs setuptools 安装问题及解决:

  1. macOS系统,执行上述安装命令后失败,提示 error: externally-managed-environment,改用 homebrew 安装 python-setuptools 解决,执行shell:brew install python-setuptools

原因:distutils 在 python3.12 中被移除,如项目需要用到 distutils,官网建议安装 setuptools 替代解决。

python官网通告 docs.python.org/zh-cn/3.10/…