Search code examples
pythonscikit-image

ImportError: cannot import name 'metrics' from 'skimage'


Here's the part that involves the use of skimage in the code:

from skimage import metrics

....

print(metrics.mean_squared_error(gray_frame, canny_img))
print(metrics.peak_signal_noise_ratio(gray_frame, canny_img))

Here's the error:


C:\Users\user\Desktop>python cannyopencv2.py
Traceback (most recent call last):
  File "cannyopencv2.py", line 6, in <module>
    from skimage import metrics
ImportError: cannot import name 'metrics' from 'skimage' (C:\ProgramData\Anaconda3\lib\site-packages\skimage\__init__.py)

Please help me get rid of it.


Solution

  • Try to install latest version of skimage because that version does not have that module in it so use below command to upgrade it!

    pip install scikit-image -U

    or

    pip install scikit-image --upgrade