pycaffe error: "ImportError: No module named skimage.io"

10,930 views
Skip to first unread message

Daniel Orf

unread,
Dec 8, 2014, 10:46:38 PM12/8/14
to caffe...@googlegroups.com
Setup:  Ubuntu 14.04 x64, CUDA 6.5, NVIDIA GTX970, ATLAS for BLAS

I've run into this error when attempting to run "import caffe" in python (script and command line).  This happens in Anaconda Python and standard Python v2.7.8 - i made a fresh install of everything including the OS (Ubuntu 14.04) to rerun on standard Python v2.7.8 to the same result.    The error output after "import caffe" is below.  I've had zero luck tracking down "skimage.io" import error.  It should be noted that I was able to "make pycaffe" successfully.  I first ran into this issue when trying out the mnist example - which I was able to train successfully, I just ran into this error when attempting to run "classify.py".

I would also like to point out that the caffe install page explicitly says not to add ~/caffe/python/caffe to your PYTHONPATH while the Interfaces page explicitly says to add this directory to your PYTHONPATH.  What gives?

with PYTHONPATH of /home/danielo/caffe/python
>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/danielo/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver
  File "/home/danielo/caffe/python/caffe/pycaffe.py", line 11, in <module>
    import caffe.io
  File "/home/danielo/caffe/python/caffe/io.py", line 2, in <module>
    import skimage.io

with PYTHONPATH of /home/danielo/caffe/python::/home/danielo/caffe/python/caffe
>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/danielo/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver
  File "/home/danielo/caffe/python/caffe/pycaffe.py", line 8, in <module>
    import numpy as np
  File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 170, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 58, in <module>
    from numpy.testing import Tester
  File "/usr/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 14, in <module>
    from .utils import *
  File "/usr/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 15, in <module>
    from tempfile import mkdtemp
  File "/usr/local/lib/python2.7/tempfile.py", line 32, in <module>
    import io as _io
  File "/home/danielo/caffe/python/caffe/io.py", line 2, in <module>
    import skimage.io
ImportError: No module named skimage.io

 Thanks everyone.

Jonathan L Long

unread,
Dec 8, 2014, 11:22:48 PM12/8/14
to Daniel Orf, caffe...@googlegroups.com
Are you trying to run something from the caffe/python/caffe directory? That can cause this error, because caffe has a module called io, which conflicts with skimage's own module called io.

What it says on the interfaces page is wrong or at least misleading (and should be clarified); caffe/python is the directory which should appear in your PYTHONPATH, not caffe/python/caffe.

JLL

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/33efcc4c-611a-41de-a4de-c2f9fa9c3e3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Orf

unread,
Dec 8, 2014, 11:27:44 PM12/8/14
to caffe...@googlegroups.com, dani...@gmail.com
I get different errors depending on whether the PYTHONPATH includes "~/caffe/python/caffe" or not (see the two different sets of errors in my first post), but it always ends with "ImportError: No module named skimage.io" regardless of the PYTHONPATH.

Thanks,
Dan

with PYTHONPATH of /home/danielo/caffe/python
>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/danielo/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver
  File "/home/danielo/caffe/python/caffe/pycaffe.py", line 11, in <module>
    import caffe.io
  File "/home/danielo/caffe/python/caffe/io.py", line 2, in <module>
    import skimage.io

Jonathan L Long

unread,
Dec 8, 2014, 11:41:51 PM12/8/14
to Daniel Orf, caffe...@googlegroups.com
Indeed. Those were meant as disjoint statements; regardless of your PYTHONPATH, you can get errors of this type if your _working directory_ is caffe/python/caffe, so you might check that.

JLL

Daniel Orf

unread,
Dec 8, 2014, 11:46:14 PM12/8/14
to caffe...@googlegroups.com, dani...@gmail.com
Good point.  Ran it again at a couple different working directories, and I get the same error regardless of working directory.

Augustus Hebblewhite

unread,
Mar 28, 2015, 3:15:45 AM3/28/15
to caffe...@googlegroups.com, dani...@gmail.com
Hi Daniel

Any luck solving this? I'm having the same issue myself.

Gus

Fabian Wahle

unread,
Apr 7, 2015, 7:17:37 AM4/7/15
to caffe...@googlegroups.com, dani...@gmail.com
pip install -U scikit-image
This should solve your problem.
Regards

Aman Verma

unread,
Apr 7, 2015, 10:00:38 AM4/7/15
to caffe...@googlegroups.com
in the installation steps there was a requirements.txt file which has all the requirements of python. Install that. That should solve all the python related issues.

du qin

unread,
Jul 4, 2015, 3:11:16 AM7/4/15
to caffe...@googlegroups.com
@Aman Verma   I have same problem . you have solved it ?

在 2015年4月7日星期二 UTC+8下午10:00:38,Aman Verma写道:

Philip H

unread,
Jul 5, 2015, 5:41:48 AM7/5/15
to caffe...@googlegroups.com
If you read closely, you will see that you're supposed to add to your PYTHONPATH=/path/to/caffe/python:$PYTHONPATH NOT  PYTHONPATH=/path/to/caffe/python/caffe:$PYTHONPATH.

That is the difference. And that should solve your problems.

If there are any other import errors, make sure you have installed all Python modules listed in caffe/python/requirements.txt

Cheers,
Phil

Srihari Rao

unread,
Apr 17, 2016, 1:15:20 PM4/17/16
to Caffe Users, dani...@gmail.com
From: 
http://scikit-image.org/docs/dev/install.html
i got caffe locally set up for DIGITS in my python path,
when i run the digits dev-server it no longer complains about unable to import caffe. the problem was just skimage.io
so i have to install scikit-image:

for debian/ubuntu:
sudo apt-get install python-skimage

now digits runs properly and is running on port 5000 and i can see in browser

Erli Lyu

unread,
May 23, 2016, 11:41:39 AM5/23/16
to Caffe Users, dani...@gmail.com
Hi, thank you. Your method solved my problem. Would you mind explain the difference between "sudo apt-get install python-skimage" and "sudo pip install scikit-image"? The later one doesn't work for me. 

在 2016年4月18日星期一 UTC+8上午1:15:20,Srihari Rao写道:

Georgios Samaras

unread,
Jun 4, 2016, 8:32:27 AM6/4/16
to Caffe Users, dani...@gmail.com
Same here. The reason is that apt-get will install patched dependencies, I asked a question on this, check it for more.
Reply all
Reply to author
Forward
0 new messages