为什么我收到错误 ModuleNotFoundError: 没有名为“distutils”的模块?
- 2025-02-21 08:47:00
- admin 原创
- 29
问题描述:
我已经安装,scikit-fuzzy
但当我import skfuzzy as fuzz
收到错误
ModuleNotFoundError: No module named 'distutils'"
我已经尝试过pip uninstall distutils
并得到了这个输出
Note: you may need to restart the kernel to use updated packages.
WARNING: Skipping distutils as it is not installed.
然后我尝试再次安装它pip install distutils
Note: you may need to restart the kernel to use updated packages.
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils
我哪里做错了?
这个问题从安装库的角度来解决这个问题。对于开发库,请参阅如何完全替换 3.10 中已弃用的 distutils?。
解决方案 1:
Python 3.12 不再带有 stdlib distutils 模块 ( changelog ),因为distutils
该模块在 3.10 中已被弃用,并在 3.12 中被删除。请参阅PEP 632 – 弃用 distutils 模块。
您仍然可以distutils
通过安装在 Python 3.12+ 上使用setuptools
。
如果这不起作用,您可能需要停留在 Python <3.12 上,直到第三方软件包(skfuzzy
在本例中)发布支持 Python 3.12 的更新版本。
解决方案 2:
distutils
模块用于安装python包。此模块通常作为python安装的一部分进行安装。
在 python v3.12 中,distutils
模块已被删除。这意味着您的本地没有任何工具来支持 python 包的安装。
为了解决此问题,请安装setuptools
相同用途的软件。
运行命令python3 -m pip install setuptools
解决方案 3:
我在导入 TensorFlow 时也遇到了同样的问题。
我的解决方案是按照以下步骤操作,
安装安装工具
导入setuptools.dist
然后 tensorflow 被导入,没有任何“ ModuleNotFoundError ”错误
解决方案 4:
brew install python-setuptools
如果您使用的是 mac 并使用 homebrew,则使用上述命令来安装缺失的模块
解决方案 5:
对于诗歌用户:
我在使用诗歌时遇到了同样的问题。
我在一台新机器上安装了 python 3.12,我的 pyproject.toml 显示:
[tool.poetry.dependencies]
python = "^3.11"
但是,它还不够“智能”,无法检测到安装了没有 setuptools 的 python 3.12。
因此将诗歌改为
[tool.poetry.dependencies]
python = "^3.12"
并运行
poetry lock
poetry install
使一切恢复正常。
解决方案 6:
如果您使用的是Void Linux,您可以通过运行以下命令解决此问题:
xi python3-setuptools
- 2025年20款好用的项目管理软件推荐,项目管理提效的20个工具和技巧
- 2024年开源项目管理软件有哪些?推荐5款好用的项目管理工具
- 2024年常用的项目管理软件有哪些?推荐这10款国内外好用的项目管理工具
- 项目管理软件有哪些?推荐7款超好用的项目管理工具
- 项目管理软件有哪些最好用?推荐6款好用的项目管理工具
- 项目管理软件哪个最好用?盘点推荐5款好用的项目管理工具
- 项目管理软件排行榜:2024年项目经理必备5款开源项目管理软件汇总
- 项目管理必备:盘点2024年13款好用的项目管理软件
- 项目管理软件有哪些,盘点推荐国内外超好用的7款项目管理工具
- 2024项目管理软件排行榜(10类常用的项目管理工具全推荐)