ModuleNotFoundError: No module named 'scipy.misc.pilutil' - python

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'

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()).

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

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

Related

sklearn module not found in anaconda

I've been trying to import sklearn but it says that the module is not found.
my python, numpy, scipy and scikit versions are as follows as show in the conda list:
numpy 1.14.3 py36h9fa60d3_1
python 3.6.5 h0c2934d_0
scipy 1.1.0 py36h672f292_0
scikit-learn 0.19.1 py36h53aea1b_0
the error while trying to import sklearn is:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-f2461ba6e1e9> in <module>()
----> 1 from sklearn.family import model
ModuleNotFoundError: No module named 'sklearn.family'
I tried using
conda update scikit-learn
conda install scikit-learn
but I get the following results
All requested packages already installed.
how do I import sklearn then?
Although there is not skleran module, from sklearn import ... works well in PyCharm:
from sklearn.utils import resample
Try doing
conda install -c anaconda pip
pip install sklearn
AFAIK, there's no sklearn.family module. Have you tried importing other modules?
Say,
from sklearn.model_selection import TimeSeriesSplit
Does that work for you?

ImportError: No module named filters

I installed skimage in ubuntu terminal using command:
sudo apt-get install python-skimage
it installed succesfully but when using it in my code (from skimage.filters import threshold_local). i get an error:
Traceback (most recent call last):
File "scan.py", line 4, in <module>
from skimage.filters import threshold_local
ImportError: No module named filters
kindly someone help me to correct this!
The problem is resolved now :D. What I found is that there is no module named 'filters' in skimage '0.10.1' as it has 'filter'. So, when I upgraded it using the command
sudo pip install --upgrade scikit-image
to version '0.13.1', it comes with the 'filters' module instead of 'filter'. The 'filters' module has all attributes of thresholding including 'local' and others as well.
So I got same problem in Spyder, Python 3.6.6.
this code (with img being a np array):
import skimage
val = skimage.filters.threshold_otsu(img)
gives: module 'skimage' has no attribute 'filters'
I tried pip install --upgrade scikit-image with no change. Skimage is indeed in my system path:
*'C:\WPy-3661\python-3.6.6.amd64\lib\site-packages', and the filters folder is in there with the init file.
but if i do:
from skimage import filters as anything
val = skimage.filters.threshold_otsu(img)
then it works. This is not normal, right ?
Note that in my sys.path paths there is only one skimage folder. So I don't think it's a duplicate issue.
I had also same problem but below code helped me:
!sudo apt-get install python-skimage
from skimage.filters import roberts, prewitt, sobel, scharr, laplace

numpy.core.multiarray failed to import

I used the following command to know the numpy version I am using
pip show numpy
output shown below
---
Name: numpy
Version: 1.8.2
Location: /usr/lib/python2.7/dist-packages
Requires:
However when I am running matplotlib, I got a error as
RuntimeError: module compiled against API version a but this version of numpy is 9
from matplotlib import pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/usr/local/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/usr/local/lib/python2.7/dist-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
I tried to upgrade numpy,
pip install numpy --upgrade
it shows to be installed successfully, but numpy still shows to be 1.8.2 and error continues to exist when running matplotlib.
I thought to uninstall numpy and reinstall it, the system gives the message saying
Not uninstalling numpy at /usr/lib/python2.7/dist-packages, owned by OS
how to solve it ?
any idea about
RuntimeError: module compiled against API version a but this version
of numpy is 9
How can I upgrade numpy? might be working for you. IN that case it was a path problem:
RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
Solution:
Check the path
import numpy
print numpy.__path__
and manually delete it using rm
I also had the same problem until I came across this Issue on Pytorch github repository. This command worked perfectly for me:
pip install numpy -I
It is also mentioned there that pip install numpy --upgrade is not working(don't know why). You can check the above mentioned link.
I had a similar problem with numpy when running torch. I tried uninstalling numpy and installing it using -U but it didn't work. After some search, I found this link and it solved my problem. It says you should change your numpy version.
pip uninstall numpy
pip install numpy==1.19.3
The answer is probably simple.
Just add
import numpy.core.multiarray
before the
import cv2
statement.
It worked fine for me.
My problem is solved using the old version of numpy. The solution is to use numpy 1.19.3.
pip install numpy==1.19.3
Credit: https://stackoverflow.com/a/64730012
Installing the previous version of NumPy, 1.19.3 should fix this.
python -m pip install numpy==1.19.3

How to install scipy misc package

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?
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.
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.

PYTHON: Error in recognising numpy module

I am using Python 3.4.0. I am going to assume that the numpy module should work, as this is one of the newer versions of python. However, anything I do with numpy will result in a syntax error. Forexample this code here:
import numpy
list1=[1,3,2,6,9]
list2=numpy.mean(list1)
print(list2)
And then I get:
Traceback (most recent call last):
File "/home/yichen/Desktop/python/numpy test.py", line 1, in <module>
import numpy
ImportError: No module named 'numpy'
Is this just a problem with my computer or what?
It looks like numpy is not installed on your system. Assuming that you have the pip script installed with your python, you can perform following command to install it:
pip install numpy
or
pip3.4 install numpy
Or, depending on your distribution, it might come as a package named like python-numpy with your package manager.

Categories

Resources