当尝试在Ubuntu 16.04上编译pycaffe时,如果安装了Anaconda 3.6,我会收到以下错误:
python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
我尝试使用
安装python-devel软件包sudo apt-get install python3-dev
sudo apt-get install python3.5-dev
sudo apt-get install python3.6-dev
但即使在分别尝试每一个之后也会发生同样的错误。
似乎在.bashrc中添加了正确的PATH
export PATH="home/jdevezas/anaconda/bin:$PATH"
在Caffe的makefile.config中我有
# 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/anaconda
#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
我也尝试使用Python 2.7但没有结果。建议?
答案 0 :(得分:-2)
对于python 2:
sudo apt-get install python-dev
对于python 3 +:
sudo apt-get install python3-dev
之后,尝试做:
locate Python.h
并使用它在makefile中找到的目录。看来头文件位于 /usr/include/python2.7 /