How to install scipy misc package

41k views Asked by At

I have installed (actually reinstalled) scipy:

10_x86_64.whl (19.8MB): 19.8MB downloaded
Installing collected packages: scipy
Successfully installed scipy

But the misc subpackage is apparently not included?

16:03:28/shared $ipython
In [1]: from scipy.misc import imread
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-f9d3d927b58f> in <module>()
----> 1 from scipy.misc import imread

ImportError: cannot import name imread

What is the way to install the scipy.misc package?

2

There are 2 answers

2
maxymoo On BEST ANSWER

I think you need to install PIL as well. From the scipy.misc docs:

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.

0
gemesyscanada On

I had same problem, running Python 2.7.12 on an old Windows XP/SP3 box. I had some stuff running on Python on MacBook, and wanted to make it work on an old Windows box. It can be done. The winbox had pip ver. 8, and I upgraded it to pip ver. 9, from within Python, using the suggestion pip provides when you run it. I had installed numpy and Pillow (current ver of PIL), using "pip install numpy" and "pip install Pillow", but "pip install scipy" and "pip install scipy.misc" failed with "no matching distribution found". I had to uninstall numpy, and then install two files: 1) numpy+mkl and then 2) scipy, both files installed are binaries for Windows, in .whl (wheel) archive format, downloaded from: http://www.lfd.uci.edu/~gohlke/pythonlibs/ site maitained by Christoph Gohlke. Find the binary versions you need for your flavour of Windows, and downloaded them into C:\some\directory. Installation order is important. First the numpy+mkl is installed, using pip, with the scipy file second. I downloaded the files from Gohlke's site, and then used pip to install them. For my old winbox, this was:

C:\some\directory\> pip install numpy-1.12.1rc1+mkl-cp27-cp27m-win32.whl

(you should see)

Installing collected packages: numpy
Successfully installed numpy-1.12.1rc1+mkl

(then, you can run)

C:\some\directory\> pip install scipy-0.18.1-cp27-cp27m-win32.whl

and you should see the "Successfully installed..." message. I had already installed Pillow. Confirm by starting Python, and trying:

>>> import numpy as np
>>> from PIL import Image, ImageDraw
>>> import scipy.misc

and all these should work. You should be able to render a .jpg with:

image = Image.open("Somefile.jpg")
image.show()

and your somefile.jpg will be displayed.