I was trying a crash course on NumPy for images and this line threw an error:
>> from skimage import data
>> camera = data.camera()
Following is the error trace of the same:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-8539ecc9e129> in <module>
----> 1 data.camera()
~/.local/lib/python3.6/site-packages/skimage/data/__init__.py in camera()
107 Camera image.
108 """
--> 109 return _load("camera.png")
110
111
~/.local/lib/python3.6/site-packages/skimage/data/__init__.py in _load(f, as_gray)
94 # we lazy import it here
95 from ..io import imread
---> 96 return imread(_os.path.join(data_dir, f), plugin='pil', as_gray=as_gray)
97
98
~/.local/lib/python3.6/site-packages/skimage/io/_io.py in imread(fname, as_gray, plugin, **plugin_args)
46
47 with file_or_url_context(fname) as fname:
---> 48 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
49
50 if not hasattr(img, 'ndim'):
~/.local/lib/python3.6/site-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
208 (plugin, kind))
209
--> 210 return func(*args, **kwargs)
211
212
~/.local/lib/python3.6/site-packages/skimage/io/_plugins/pil_plugin.py in imread(fname, dtype, img_num, **kwargs)
34 with open(fname, 'rb') as f:
35 im = Image.open(f)
---> 36 return pil_to_ndarray(im, dtype=dtype, img_num=img_num)
37 else:
38 im = Image.open(fname)
~/.local/lib/python3.6/site-packages/skimage/io/_plugins/pil_plugin.py in pil_to_ndarray(image, dtype, img_num)
64 while 1:
65 try:
---> 66 image.seek(i)
67 except EOFError:
68 break
~/.local/lib/python3.6/site-packages/PIL/PngImagePlugin.py in seek(self, frame)
737
738 def seek(self, frame):
--> 739 if not self._seek_check(frame):
740 return
741 if frame < self.__frame:
~/.local/lib/python3.6/site-packages/PIL/ImageFile.py in _seek_check(self, frame)
304 raise EOFError("attempt to seek outside sequence")
305
--> 306 return self.tell() != frame
307
308
~/.local/lib/python3.6/site-packages/PIL/PngImagePlugin.py in tell(self)
825
826 def tell(self):
--> 827 return self.__frame
828
829 def load_prepare(self):
AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'
What is the problem here? I'm using skimage 0.16.2, Python 3.6.9 on Ubuntu 18.04.3 LTS.
I have plenty of experience with Scikit-Learn but a newbie to image processing and skimage.
This is an error with the latest release of Pillow (7.1.0). They have been rushing to fix it and you should soon be able to fix the problem by doing pip install -U Pillow
. Monitor this page for the next release after 7.1.
You can also install the previous version, pip install Pillow==7.0.0
.