Can't complete make pycaffe (Python.h not found)

125 views
Skip to first unread message

João Devezas

unread,
Feb 16, 2018, 5:41:22 PM2/16/18
to Caffe Users
I'm installing Caffe on an Ubuntu 16.04 system with CUDA 9.1 and cuDNN 7.0.5

I successfully compiled Caffe with the "make all" command but when trying to compile pycaffe with "make pycaffe" I get the following error:

    CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
    python
/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
    compilation terminated
.
   
Makefile:507: recipe for target 'python/caffe/_caffe.so' failed
    make
: *** [python/caffe/_caffe.so] Error 1


I'm using Anaconda 2.7.14 which is located at (with 'which conda' command):

    /home/jdevezas/anaconda2/bin/conda

Here's how the makefile.config for Caffe looks:

    # NOTE: this is required only if you will compile the python interface.
   
# We need to be able to find Python.h and numpy/arrayobject.h.
   
#PYTHON_INCLUDE := /usr/include/python2.7 \
   
/usr/lib/python2.7/dist-packages/numpy/core/include
   
# Anaconda Python distribution is quite popular. Include path:
   
# Verify anaconda location, sometimes it's in root.
     ANACONDA_HOME
:= /home/jdevezas/anaconda2
     PYTHON_INCLUDE
:= $(ANACONDA_HOME)/include \
    $
(ANACONDA_HOME)/include/python2.7 \
    $
(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
   
   
# Uncomment to use Python 3 (default is Python 2)
   
# PYTHON_LIBRARIES := boost_python3 python3.5m
   
# PYTHON_INCLUDE := /usr/include/python3.5m \
   
#                 /usr/lib/python3.5/dist-packages/numpy/core/include
   
   
# We need to be able to find libpythonX.X.so or .dylib.
   
# PYTHON_LIB := /usr/lib
     PYTHON_LIB
:= $(ANACONDA_HOME)/lib


I have the following line at the end of the .bashrc file:



       
# added by Anaconda2 installer
   
export PATH="/home/jdevezas/anaconda2/bin:$PATH"


Any help would be appreciated

Anwesha Chatterjee

unread,
Feb 19, 2018, 4:07:45 AM2/19/18
to Caffe Users
I think you need to set PYTHONPATH to the python directory located inside the caffe root.
Reply all
Reply to author
Forward
0 new messages