when I run "make py", the following error appears. I am using anaconda3, with python3.5.
I have also installed libopenblas-dev, python-numpy, python-dev .
python/swigfaiss_wrap.cxx:173:21: fatal error: Python.h: No such file or directory
compilation terminated.
Makefile:84: recipe for target 'python/_swigfaiss.so' failed
make: * [python/_swigfaiss.so] Error 1
Hi
Please check the include directory for python in makefile.inc
@mdouze Thank you for your quick help. I changed the PYTHONCFLAGS in the makefile.inc to the following, and now "make py" works.
PYTHONCFLAGS=-I/usr/include/python3.5/ -I$HOME/anaconda3/lib/python3.5/site-packages/numpy/core/include
But I think this configuration is not quite right. There are errors when I tried to import faiss. I hope there are more detail guides regarding the installation of Faiss, e.g. how to install under anaconda. Anyway, thanks for your help and for your great work!
also have the same troubles. @zhouyoupku , did you fixed?
this question : python/swigfaiss_wrap.cpp:173:21: fatal error: Python.h: No such file or directory
you should install swig
If you hit this error, then define SWIG for make:
% make CC=gcc-6 CPP=g++-6 CXX=g++-6 -j 16 py
make -C python
make[1]: Entering directory '../code/faiss/python'
python -c++ -Doverride= -I../ -DSWIGWORDSIZE64 -DGPU_WRAPPER -o swigfaiss.cpp swigfaiss.swig
File "<string>", line 1
++
SyntaxError: invalid syntax
Makefile:16: recipe for target 'swigfaiss.cpp' failed
make[1]: [swigfaiss.cpp] Error 1 (ignored)
g++-6 -DFINTEGER=int -fopenmp -I/usr/local/cuda-9.0/include -fPIC -m64 -Wno-sign-compare -g -O3 -Wall -Wextra -mpopcnt -mavx2 -mf16c -I \
-I../ -c swigfaiss.cpp -o swigfaiss.o
g++-6: error: swigfaiss.cpp: No such file or directory
g++-6: fatal error: no input files
compilation terminated.
Makefile:19: recipe for target 'swigfaiss.o' failed
make[1]: *** [swigfaiss.o] Error 1
make[1]: Leaving directory '/.../code/faiss/python'
Makefile:81: recipe for target 'py' failed
make: *** [py] Error 2
The solution was that swig executable wasn't defined. Fixed by running make with make SWIG=/usr/bin/swig that will generate the cpp files for compilation, otherwise it was substituting an empty string for SWIG in Makefile, which was causing python to execute and -c++ is interpreted as "execute command ++" which is a python syntax error.
Also you have to install swig to make solution from @programWhiz work.
Btw, are there any requirements needed to compile faiss?
Hi
Please check the include directory for python in makefile.
@mdouze Thank you for your quick help. I changed the PYTHONCFLAGS in the makefile.inc to the following, and now "make py" works.
PYTHONCFLAGS=-I/usr/include/python3.5/ -I$HOME/anaconda3/lib/python3.5/site-packages/numpy/core/include
But I think this configuration is not quite right. There are errors when I tried to import faiss. I hope there are more detail guides regarding the installation of Faiss, e.g. how to install under anaconda. Anyway, thanks for your help and for your great work!
this one not works for me, not sure why
If you hit this error, then define SWIG for make:
% make CC=gcc-6 CPP=g++-6 CXX=g++-6 -j 16 py make -C python make[1]: Entering directory '../code/faiss/python' python -c++ -Doverride= -I../ -DSWIGWORDSIZE64 -DGPU_WRAPPER -o swigfaiss.cpp swigfaiss.swig File "<string>", line 1 ++ SyntaxError: invalid syntax Makefile:16: recipe for target 'swigfaiss.cpp' failed make[1]: [swigfaiss.cpp] Error 1 (ignored) g++-6 -DFINTEGER=int -fopenmp -I/usr/local/cuda-9.0/include -fPIC -m64 -Wno-sign-compare -g -O3 -Wall -Wextra -mpopcnt -mavx2 -mf16c -I \ -I../ -c swigfaiss.cpp -o swigfaiss.o g++-6: error: swigfaiss.cpp: No such file or directory g++-6: fatal error: no input files compilation terminated. Makefile:19: recipe for target 'swigfaiss.o' failed make[1]: *** [swigfaiss.o] Error 1 make[1]: Leaving directory '/.../code/faiss/python' Makefile:81: recipe for target 'py' failed make: *** [py] Error 2The solution was that swig executable wasn't defined. Fixed by running make with
make SWIG=/usr/bin/swigthat will generate the cpp files for compilation, otherwise it was substituting an empty string for SWIG in Makefile, which was causing python to execute and-c++is interpreted as "execute command++" which is a python syntax error.
this one also not works for me, could you please provide more hints? Thank you
@ninnyyan Please open a separate issue
this question : python/swigfaiss_wrap.cpp:173:21: fatal error: Python.h: No such file or directory
you should install swig
...and reconfigure
Most helpful comment
If you hit this error, then define SWIG for make:
The solution was that swig executable wasn't defined. Fixed by running make with
make SWIG=/usr/bin/swigthat will generate the cpp files for compilation, otherwise it was substituting an empty string for SWIG in Makefile, which was causing python to execute and-c++is interpreted as "execute command++" which is a python syntax error.