problem with io.imread

3,587 views
Skip to first unread message

Julien Derr

unread,
Apr 29, 2015, 12:21:21 PM4/29/15
to scikit...@googlegroups.com
Hi everyone,
I have a very basic problem, but I have no idea how to solve it !
I installed scikitimage on a new computer, and I cannot manage to load an image with the io module

from skimage import io,  works fine :

Variable   Type      Data/Info
------------------------------
filename   str       ./small.jpg
io         module    <module 'skimage.io' from<...>skimage/io/__init__.pyc'>

but when I want to load my image: I get the error

In [5]: camera = io.imread(filename)

ValueError: Could not load "./small.jpg"
Please see documentation at: http://pillow.readthedocs.org/en/latest/installation.html#external-libraries


I went on the website where they ask to unistall PIL before installing pillow, this is what I did, and still I get the error ...

any ideas ?


thanks a lot!

Julien

Emmanuelle Gouillart

unread,
Apr 29, 2015, 12:26:55 PM4/29/15
to scikit...@googlegroups.com
Hi Julien,

how did you install scikit-image? Are you using a scientific Python
distribution such as Anaconda or Canopy? Did you try re-installing
scikit-image after installing pillow?

Which version of scikit-image did you install?

Emma

Stefan van der Walt

unread,
Apr 30, 2015, 1:58:18 AM4/30/15
to scikit...@googlegroups.com
Hi Julian

On 2015-04-29 09:21:00, Julien Derr <julie...@gmail.com> wrote:
> ValueError: Could not load "./small.jpg" Please see
> documentation at:
> http://pillow.readthedocs.org/en/latest/installation.html#external-libraries

What that document tells you is that you should first install
libjpeg, then install (or re-install) PIL, and then the loader
should work.

Alternatively, you can try:

from skimage import io
io.imread('./small.jpg', plugin='matplotlib')

Other options include:

- https://pypi.python.org/pypi/imageio
- https://pypi.python.org/pypi/imread

Regards
Stéfan

Julien Derr

unread,
May 2, 2015, 8:06:05 AM5/2/15
to scikit...@googlegroups.com
Thanks everyone for all the answers,

I tried to desinstal reinstall with many variations. my last choice was :

scikit-image==0.12dev
 easy_install -U scikit-image

I tried your option; with plugin='matplotlib' and still get the following error message, so it looks like I have indeed a problem with a jpeg decoder, but I checked that 
I have the package libjpeg8 installed already.



Traceback (most recent call last):
  File "test.py", line 17, in <module>
    rgb=io.imread(cheminfichier,plugin='matplotlib')
  File "/usr/local/lib/python2.7/dist-packages/scikit_image-0.12dev-py2.7-linux-x86_64.egg/skimage/io/_io.py", line 100, in imread
    img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
  File "/usr/local/lib/python2.7/dist-packages/scikit_image-0.12dev-py2.7-linux-x86_64.egg/skimage/io/manage_plugins.py", line 207, in call_plugin
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 2215, in imread
    return _imread(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/image.py", line 1254, in imread
    im = pilread(fname)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/image.py", line 1235, in pilread
    return pil_to_array(image)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/image.py", line 1344, in pil_to_array
    x = toarray(im)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/image.py", line 1327, in toarray
    x_str = im.tobytes('raw', im.mode)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 661, in tobytes
    self.load()
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 203, in load
    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 419, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available

Stefan van der Walt

unread,
May 2, 2015, 7:30:39 PM5/2/15
to scikit...@googlegroups.com
Hi Julien

On 2015-05-02 05:06:05, Julien Derr <julie...@gmail.com> wrote:
> I tried your option; with plugin='matplotlib' and still get the
> following error message, so it looks like I have indeed a
> problem with a jpeg decoder, but I checked that I have the
> package libjpeg8 installed already.

Your PIL seems broken. I would completely remove PIL, make sure
libjpeg and libjpeg-dev is installed, and then install Pillow
instead.

Stéfan

Julien Derr

unread,
May 4, 2015, 11:41:30 AM5/4/15
to scikit...@googlegroups.com
thanks a lot !

Emmanuelle Gouillart

unread,
May 4, 2015, 11:55:16 AM5/4/15
to scikit...@googlegroups.com
did it work?

Julien Derr

unread,
May 13, 2015, 2:36:37 PM5/13/15
to scikit...@googlegroups.com
Hi Emmanuelle,
It didn't work, it seemed my installation was completely messy ...
I wanted for a long time to move to archlinux, so it was the occasion ...

Under arch, the installation was super smooth! and now it works! :-)

thanks again for the help,

Julien

Hélder Tomas

unread,
Jun 5, 2015, 4:05:29 AM6/5/15
to scikit...@googlegroups.com
Hello guys,

I had the same issue and it's due to PIL and the libraries needed to read jpeg. It worked fine with png for instance.
Pillow has replaced pil, and we might as well remove pil.

Remove PIL:
sudo pip uninstall pil

Install the required libraries:
 sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

Install/upgrade pillow :
sudo pip install pillow --upgrade

And your data.imread should work fine now.

Hope this helps someone!

Stefan van der Walt

unread,
Jun 5, 2015, 2:37:27 PM6/5/15
to scikit...@googlegroups.com
Dear Hélder

On 2015-06-05 01:01:02, Hélder Tomas <helde...@gmail.com> wrote:
> I had the same issue and it's due to PIL and the libraries
> needed to read jpeg. It worked fine with png for instance.
> Pillow has replaced pil, and we might as well remove pil.

Can we catch this problem and then display a workaround to the
user? Would you be interested in working on that?

Stéfan
Reply all
Reply to author
Forward
0 new messages