Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "-scipy.misc has no attribute "imresize""

I have some code from my friend. He run it smoothly but I encounter

module **scipy.misc** has no attribute *imresize*

I'm searching, installed Pillow (PIL), scipy, scikit,.. but dont work

I asked my friend but he forgot what he has installed.

like image 424
I'mMotivated Avatar asked May 19 '19 05:05

I'mMotivated


4 Answers

If you check the documentation for scipy.misc.imresize from many recent versions of scipy, you'll find the following line up at the top:

imresize is deprecated! imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0. Use Pillow instead: numpy.array(Image.fromarray(arr).resize()).

The 1.3.0 release happened yesterday, so if you downloaded scipy on your system today, you may have got the new version, which won't have access to that function any longer. The documentation I quoted above suggests a code fragment (using numpy and PIL) that should work as an alternative.

like image 96
Blckknght Avatar answered Nov 13 '22 16:11

Blckknght


scipy.misc.imresize is depricated.

There are two alternatives

  1. As pointed by @Bickknght we can use PIL (Pillow)library.

    from PIL import Image
    numpy.array(Image.fromarray(arr).resize())
    
  2. Using Skimage

    from skimage.transform import resize
    from skimage import data
    image = data.camera()
    resize(image, (100, 100))
    
like image 10
shantanu pathak Avatar answered Nov 13 '22 14:11

shantanu pathak


Install scipy(1.2.2) this will work.

pip install scipy==1.2.2

If still not work --> install pillow

pip install Pillow

scipy.misc.imresize - Resize an image [requires Pillow]

OR

help('scipy.misc.imresize')

scipy.misc.imresize = imresize(*args, **kwds)
`imresize` is deprecated!
`imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.
Use Pillow instead: ``numpy.array(Image.fromarray(arr).resize())``.

Resize an image.

This function is only available if Python Imaging Library (PIL) is installed.
like image 4
Anand Biswas Avatar answered Nov 13 '22 16:11

Anand Biswas


This worked for me:

pip install scipy==1.2.2
like image 2
A Raze Avatar answered Nov 13 '22 15:11

A Raze