2

I am trying to read an image from scipy. But it give the error "no attribute 'imread'". What could cause for this?

AttributeError                            Traceback (most recent call last)
<ipython-input-29-311aa4fc2e10> in <module>
      5 
      6 fname = "images/" + my_image
----> 7 image = np.array(ndimage.imread(fname, flatten=False))
      8 my_image = scipy.misc.imresize(image, size=(num_px,num_px)).reshape((num_px*num_px*3,1))
      9 my_image = my_image/255.

AttributeError: module 'scipy.ndimage' has no attribute 'imread'
Timus
  • 10,974
  • 5
  • 14
  • 28
  • 1
    U can use `print(help(scipy.ndimage))` to see all the attributes – Shadowcoder Nov 27 '20 at 07:06
  • I don't believe this is a duplicate. The linked Q&A dialog specifically has the code, `scipy.misc.imread({image-filename})`. I would have had a hard time finding those answers, being that my code included `img = scipy.ndimage({image-filename})`. I think it would be difficult to find the other, given that its error was `AttributeError: 'module' object has no attribute 'imread'`, while mine was `AttributeError: module 'scipy.ndimage' has no attribute 'imread'`. – bballdave025 Mar 04 '23 at 21:11

1 Answers1

5

From the documentation of SciPy:

imread is deprecated! imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead.

This means if you are using any SciPy version 1.2.0 or above, you are likely to see this error message for using ndimage.imread function.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Kasid Khan
  • 639
  • 2
  • 8
  • 23