Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import scipy.misc.imread

Tags:

python

scipy

I've seen this problem before with other people, but haven't found a fix.

All I'm trying to do is:

from scipy.misc import imread

and I get

/home1/users/joe.borg/<ipython-input-2-f9d3d927b58f> in <module>() ----> 1 from scipy.misc import imread  /software/Python/272/lib/python2.7/site-packages/scipy/misc/__init__.py in <module>()      16 try:      17     from pilutil import * ---> 18     __all__ += pilutil.__all__      19 except ImportError:      20     pass  NameError: name 'pilutil' is not defined 

But it's fine when I do from pilutil import * on its own (no import error). Even .../site-packages/scipy/misc/pilutil.py exists so I've got no idea why this is failing.

like image 936
joedborg Avatar asked Feb 15 '12 17:02

joedborg


People also ask

How do I install SciPy MISC in Python?

Install SciPy using the pip command Python consists of pip command which is an official package installer. It is a package manager, we can install, delete, or update any package. We need to install pip for using the pip command.

What is MISC in SciPy?

misc) Various utilities that don't have another home. Note that the Python Imaging Library (PIL) is not a dependency of SciPy and therefore the pilutil module is not available on systems that don't have PIL installed.

How do I download SciPy?

Type and run pip install scipy in the command prompt. This will use the Python Package index, and install the core SciPy packages on your computer. You can also install other core packages like Numpy and Matplotlib by using the pip install numpy and pip install matplotlib commands.

Is it possible to use imread in SciPy?

however, you might want to think about switching to scipy.imageio.imread since scipy.misc.imread is deprecated : imread is deprecated! imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead Show activity on this post. it worked for me. Show activity on this post.

How to read an image from a SciPy file?

You also need to install PIL (Pillow) as that is what scipy uses to read images: imread uses the Python Imaging Library (PIL) to read an image.

Is there a Python module that has no attribute ‘imread’?

TensorFlow Long Short-Term Memory Network PyTorch Machine Learning WordPress PHP Linux Matplotlib PyQT5 Fix Python module ‘scipy.misc’ has no attribute ‘imread’ – Python Tutorial By admin|June 16, 2020 2 Comments When you are processing images using python, you may encounter this error: module ‘scipy.misc’ has no attribute ‘imread’.

Is imread deprecated in Python?

imread is deprecated! imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead. Read an image from a file as an array. This function is only available if Python Imaging Library (PIL) is installed.


1 Answers

If you have Pillow installed with scipy and it is still giving you error then check your scipy version because it has been removed from scipy since 1.3.0rc1.

rather install scipy 1.1.0 by :

pip install scipy==1.1.0

check https://github.com/scipy/scipy/issues/6212

like image 107
user_3pij Avatar answered Oct 27 '22 00:10

user_3pij