macOS 在make pycaffe时报错fatal error: 'Python.h' file not found解决

安装完caffe,在caffe/build中执行make pycaffe时,报出以下错误:

 linxierdeAir:caffe linxier$ cd build
linxierdeAir:build linxier$ make pycaffe
[  1%] Built target caffeproto
[ 98%] Built target caffe
[ 98%] Building CXX object python/CMakeFiles/pycaffe.dir/caffe/_caffe.cpp.o
/Users/linxier/caffe/python/caffe/_caffe.cpp:1:10: fatal error: 'Python.h' file
      not found
#include   // NOLINT(build/include_alpha)
         ^~~~~~~~~~
1 error generated.
make[3]: *** [python/CMakeFiles/pycaffe.dir/caffe/_caffe.cpp.o] Error 1
make[2]: *** [python/CMakeFiles/pycaffe.dir/all] Error 2
make[1]: *** [python/CMakeFiles/pycaffe.dir/rule] Error 2
make: *** [pycaffe] Error 2

解决方法:

export CPLUS_INCLUDE_PATH=/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7

参考链接:https://stackoverflow.com/questions/35778495/fatal-error-python-h-file-not-found-while-installing-opencv
将路径名称改为自己电脑中含有Python.h的文件夹路径,之后编译成功。

你可能感兴趣的:(caffe)