fatal error: numpy/arrayobject.h: No such file or directory
when compiling I am getting the following error
fatal error: numpy/arrayobject.h: No such file or directory
Python 2.7 and 3 already installed. Numpy is installed. cython is installed. using ubuntu 16.04
According to https://packages.ubuntu.com/search?searchon=contents&keywords=numpy%2Farrayobject.h&mode=exactfilename&suite=xenial&arch=any there are three packages for xenial containing this file, if you have installed one of them it should be just a matter of verifying that the include path points to the correct location.
I'm having the same issue on macOS. I've tried linking with Python 2.7 and 3.6 paths. Doesn't work for either. Using homebrew for my 3.6 install.
I'm getting the actual path using this variable in my makefile (fix the python interpreter to python2 or python3 to reflect your installation if needed), OS X Mojave:
NUMPY_INCLUDE := -I$(shell python -c 'import numpy; print(numpy.get_include())')
Also, if using homebrew on Mac OS X try using the python2-config or python3-config script to retrieve --ldflags and --cflags compilation parameters.
Anyway, I'm able to make it work with python2 only (after fixing matplotlibrc backend). I'm having run-time issues when trying to use Python 3.7.x
if you used pip2 to install numpy then you should need this flag to g++
-I /usr/local/lib/python2.7/site-packages/numpy/core/include/
Same issue, manually find numpy/arrayobject.h at
/usr/local/lib/python3.5/dist-packages/numpy/core/include
Therefore,
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} /usr/local/lib/python3.5/dist-packages/numpy/core/include)
could be a provisional solution.
I found a solution, in short:
-
Download this zip file, and extract it where you have "matplotlibcpp.h"; the extracted files should be put in a directory called "numpy". numpy.zip
-
Go to "matplotlibcpp.h" file and open it, in line (20), edit:
# include <numpy/arrayobject.h>to:# include "numpy/arrayobject.h"
Explanation: I couln't install "arrayobject.h" (as it should come with numpy if I'm not wrong) using pip or any package manager, so I went here: https://github.com/huggingface/neuralcoref/tree/master/include/numpy Then I download the folder using an online tool and bang! it worked.