matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

fatal error: numpy/arrayobject.h: No such file or directory

Open ghost opened this issue 8 years ago • 6 comments

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

ghost avatar Dec 27 '17 05:12 ghost

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.

lava avatar Jan 02 '18 11:01 lava

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.

joelrorseth avatar Feb 12 '18 01:02 joelrorseth

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

rene-aguirre avatar Nov 27 '18 07:11 rene-aguirre

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/

asharif avatar Dec 13 '18 04:12 asharif

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.

XiaoxingChen avatar Jun 05 '19 13:06 XiaoxingChen

I found a solution, in short:

  1. 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

  2. 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.

Mohyoo avatar Oct 20 '24 14:10 Mohyoo