Andrea Di Biagio Andrea Di Biagio - 1 year ago 371
Python Question

make pycaffe fatal error: 'Python.h' file not found

I compiled caffe on a mac running OSX 10.9.5 and I know trying to compile pycaffe. When I run make pycaffe in the caffe root folder, I get:

CXX/LD -o python/caffe/ python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:1:10: fatal error: 'Python.h' file not found
#include <Python.h> // NOLINT(build/include_alpha)
1 error generated.
make: *** [python/caffe/] Error 1

how can I fix this?

Perhaps is something wrong with Makefile.config. How do I know what is my PYTHONPATH?

Answer Source

Looking at the comments, I see that you use Anaconda. In Makefile.config, you should uncomment the lines dedicated to Anaconda:

# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
        # $(ANACONDA_HOME)/include/python2.7 \
        # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

# We need to be able to find or .dylib.
PYTHON_LIB := /usr/lib

Python.h is in $(ANACONDA_HOME)/include/python2.7 as you can see running sudo find / -name 'Python.h'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download