2

I am not able to import scipy.misc.pilutil

Though I have pillow and scipy installed. I am able to import scipy.misc but can't use functions like imresize

from scipy.misc.pilutil import imresize

ModuleNotFoundError                       
Traceback (most recent call last)

<ipython-input-20-a7ba6cfb7450> in <module>()
----> 1 from scipy.misc.pilutil import imsave

ModuleNotFoundError: No module named 'scipy.misc.pilutil'
Itamar Mushkin
  • 2,803
  • 2
  • 16
  • 32
Meghna
  • 73
  • 2
  • 9
  • What version of scipy do you have? Works for me on scipy 1.1.0 – Itamar Mushkin Jul 14 '19 at 10:08
  • @ItamarMushkin I am using scipy 1.3.0 ant the version of pillow is 6.1.0 – Meghna Jul 14 '19 at 10:12
  • @meghnakapoor do you have multiple installs of python or virtual environments? If that is the case make sure you are running the intended python version and / or virtual environment. – Mr. Radical Jul 14 '19 at 20:13
  • @Mr.Radical I am using google colab and I don't have any other environment there. – Meghna Jul 15 '19 at 06:12
  • 1
    @meghnakapoor I found this on how to install a package in colab: https://stackoverflow.com/questions/51342408/how-do-i-install-python-packages-in-googles-colab#51343539. Basically you need to prepend each pip command with !. So maybe you could try `!pip list`to show a list of packages you installed (https://stackoverflow.com/questions/6600878/find-all-packages-installed-with-easy-install-pip). It worked for me with jupyter notebook. – Mr. Radical Jul 15 '19 at 13:06

3 Answers3

2

You get this error because you are using scipy v1.3.0 and imresize() is deprecated. Also make sure you have Pillow installed.

See here: https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.imresize.html

"imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0."

Either downgrade to v1.2.x or use Pillow resize() instead: numpy.array(Image.fromarray(arr).resize()).

Mike S.
  • 118
  • 7
0

Check your scipy version. I had the same issue and after I've changed the scipy version to 1.1.0. the issue disappeared.

To check the scipy version in the terminal:

import scipy 
scipy.version.full_version
0

The newer version of scipy has removed the imsave and many other functions such as resize, you can install older version of scipy with following:

pip install scipy==1.1.0
KingLiu
  • 59
  • 4