关于Matplotlib实验中出现NameError: name ‘rgb2gray‘ is not defined的解决

唉,这个问题搞了老半天!!!

废话少说,直接上解决方案:1:终端pip install install scikit-image

                                            2:python项目中from skimage.color import rgb2gray

        完美解决!!!

以下是解决经历:

看的matplotlib显示图像实验中引用了marplotlib.pyplot后直接使用rgb2gray函数,但自己用时就出现了NameError: name 'rgb2gray' is not defined的错误。

翻找了很长时间发现是缺少一个库

大佬kakaccys在一个问题下评论需要加上:from skimage.color import rgb2gray

我直接去pip但是又出现了

Collecting skimage
  Downloading skimage-0.0.tar.gz (757 bytes)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]

      *** Please install the `scikit-image` package (instead of `skimage`) ***

      [end of output]

  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.

[notice] A new release of pip available: 22.2.1 -> 22.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip

看到Please install the 'scikit-image'packge

pip了这个全称结果就可以了

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值