中
尝试在Ubuntu上编译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
中添加了正确的路径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,没有结果。建议?
for Python 2:
sudo apt-get install python-dev
对于Python 3 :
sudo apt-get install python3-dev
之后,尝试做:
locate Python.h
并使用它在makefile中找到的目录。看来标题文件在/usr/include/python2.7/
首先检查安装了哪个版本的Python。假设版本3.11。克隆回购后,转到'build.sh'文件,然后将GCC线编辑为Python版本,即3.8至3.11。
gcc -Os -I /usr/include/python3.8 -o torghost torghost.c -lpython3.8 -lpthread -lm -lutil -ldl
to
gcc -Os -I /usr/include/python3.11 -o torghost torghost.c -lpython3.11 -lpthread -lm -lutil -ldl
现在它将构建和编译。