安装scikit-image==0.16.2报错

该文章已生成可运行项目,

输入pip install scikit-image==0.16.2 报错如下:

Collecting scikit-image==0.16.2
  Using cached scikit-image-0.16.2.tar.gz (28.9 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      /tmp/pip-install-94361s0i/scikit-image_ed96910f4a29471eabab4acc826fc4be/setup.py:167: DeprecationWarning:

        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
        of the deprecation of `distutils` itself. It will be removed for
        Python >= 3.12. For older Python versions it will remain present.
        It is recommended to use `setuptools < 60.0` for those Python versions.
        For more details, see:
          https://numpy.org/devdocs/reference/distutils_status_migration.html  


        from numpy.distutils.core import setup
      ·······

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

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

报错原因:

numpy.distutils 已被弃用,并且与当前环境中的 setuptools 版本不兼容。numpy.distutils 从 NumPy 1.23.0 开始被弃用,并且仅与 setuptools < 60.0 版本测试过。错误信息中提到 ModuleNotFoundError: No module named 'distutils.msvccompiler',这表明 numpy.distutils 试图使用 distutils 的一个不存在的模块。

解决方法:

 

此错误发生在尝试安装 `scikit-image==0.16.2` 时,原因是 `numpy.distutils` 已被弃用,并且与当前环境中的 `setuptools` 版本不兼容。`numpy.distutils` 从 NumPy 1.23.0 开始被弃用,并且仅与 `setuptools < 60.0` 版本测试过。错误信息中提到 `ModuleNotFoundError: No module named 'distutils.msvccompiler'`,这表明 `numpy.distutils` 试图使用 `distutils` 的一个不存在的模块。

要解决这个问题,你可以尝试以下步骤:

1. 降级 `setuptools`(我用的这个)

由于 `numpy.distutils` 与 `setuptools` 的新版本存在兼容性问题,你可以尝试将 `setuptools` 降级到 60.0 或更低版本:

pip install setuptools==59.8.0

然后再次尝试安装 `scikit-image==0.16.2`。

2. 使用 `pip` 的 `--no-deps` 选项

这个选项可以防止 `pip` 安装不需要的依赖项,有时候这可以绕过兼容性问题:

pip install --no-deps scikit-image==0.16.2

3. 使用 `conda` 安装

如果你使用的是 Anaconda 或 Miniconda,可以尝试使用 `conda` 来安装 `scikit-image`,因为 `conda` 通常会处理这些依赖关系:

conda install scikit-image=0.16.2

4. 手动安装依赖

如果问题仍然存在,你可以尝试手动安装 `scikit-image` 的依赖,然后再安装 `scikit-image`。这可能需要一些额外的步骤来确保所有依赖都正确安装。

 5. 更新 `pip`

确保你的 `pip` 是最新版本,因为旧版本的 `pip` 可能无法正确处理依赖关系:

pip install --upgrade pip

 6. 检查 Python 版本

确保你的 Python 版本与 `scikit-image` 和其他库兼容。有时候,库的特定版本可能只支持 Python 的特定版本。

 7. 环境变量

在安装过程中设置环境变量 `SETUPTOOLS_USE_DISTUTILS=stdlib`,以避免 `setuptools` 使用其自带的 `distutils` 副本:

SETUPTOOLS_USE_DISTUTILS=stdlib pip install scikit-image==0.16.2

本文章已经生成可运行项目
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值