Unable to import caffe

I executed make pycaffe in the caffe directory and it worked fine. I also did this:

gsamaras@gsamaras-A15:~/caffe/python$ export PYTHONPATH=$PYTHONPATH:/home/gsamaras/caffe/python

but when I try to import caffe in another project, I get this:

ImportError: No module named caffe

How to fix this?

Also note that in the Makefile.config of caffe, there is this line:

PYTHON_INCLUDE := /usr/include/python2.7 \ <-- correct /usr/lib/python2.7/dist-packages/numpy/core/include <-- doesn't exist

My numpy version is 1.11.



<ol> <li>Import caffe error</li> <li>Python interface of Caffe: Error in "import caffe"</li> </ol> <hr>


I found this, which suggests pip install -U scikit-image, but it fails with:

Running setup.py (path:/tmp/pip_build_root/scikit-image/setup.py) egg_info for package scikit-image warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests' warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests' warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests' warning: no files found matching '*.pxd' under directory 'Cython/Utility' ... Downloading/unpacking decorator>=3.4.0 (from networkx>=1.8->scikit-image) Downloading decorator-4.0.9-py2.py3-none-any.whl Cleaning up... Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1091, in prepare_files req_to_install.check_if_exists() File "/usr/lib/python2.7/dist-packages/pip/req.py", line 811, in check_if_exists self.satisfied_by = pkg_resources.get_distribution(self.req) File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 535, in get_distribution dist = get_provider(dist) File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 415, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] IndexError: list index out of range

and now I am getting this error:

ImportError: No module named skimage.io


sudo apt-get install python-skimage worked for me.


I had to use sudo apt-get install -U scikit-image after all! The reason is: Didn't work with pip, but worked with apt-get?


I encountered similar error in my caffe installation when I try to import skimage.io. However, when I tried to install the skimage via pip, it fails with the same message posted above.

Then I tried using apt-get to install scikit-image. It finished successfully. Unfortunately, it installed outdated version which cause another error in my code.

Finally, I have found a workaround by first installing virtualenv and fresh installing those libraries (scikit-image, scipy, matplotlib, etc) using pip. My caffe now worked flawlessly. Hope this helps other in the same situation.


  • Is there a way to use recursive feature selection with non linear models with scikit-learn?
  • SciKit One-class SVM classifier training time increases exponentially with size of training data
  • how to convert this date string to “2011-02-15T12:00+00:00” python datetime object
  • Can't install scipy
  • Web API Basic Auth inside an MVC app with Identity Auth
  • Map predictions back to IDs - Python Scikit Learn DecisionTreeClassifier
  • SiteMesh: Changing the content-type of the response
  • Disadvantages to high make job values
  • how to enforce Monotonic Constraints in XGBoost with ScikitLearn?
  • const char **a = {“string1”,“string2”} and pointer arithametic
  • Error while installing ggplot in python
  • How to install PyAutoGUI
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Prevent page break in text block with iText, XMLWorker
  • Python 3.2.2, error(scripts to exe)
  • NSIS decompiler
  • Why must we declare a variable name when adding a method to a struct in Golang?
  • Python ImageIO Gif Set Delay Between Frames
  • OSX - always hide certain files
  • Compiling dlib on OS X
  • npm 5.4.1 install/uninstall all failing
  • How to generate and display a QR Code in ionic 2
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Problem while Building a Setup Project for a windows Service?
  • Textfile Structure (tables)
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Python urlparse: small issue
  • FileReader+canvas image loading problem
  • req.body is undefined - nodejs
  • Fetching methods from BroadcastReceiver to update UI
  • Running a C# exe file
  • Symfony2: How to get request parameter
  • ActionScript 2 vs ActionScript 3 performance
  • How can I estimate amount of memory left with calling System.gc()?
  • Apache 2.4 - remove | delete | uninstall
  • GridView Sorting works once only
  • WPF Applying a trigger on binding failure
  • python draw pie shapes with colour filled