唉,这个问题搞了老半天!!!
废话少说,直接上解决方案: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了这个全称结果就可以了