1

I am trying to compile a project using cmake. This is the relevant CMakeLists.txt code snippet.

set(PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.6/dist-packages/numpy/core/include/)
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} /usr/local/lib/python3.6/dist-packages/numpy/core/include)
find_package(Python COMPONENTS Interpreter Development)
find_package(PythonLibs REQUIRED)
...
include_directories( ${PYTHON_INCLUDE_DIRS} )

To ensure that it is working properly, I print the relevant info

execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE OUTPUT_STRIP_TRAILING_WHITESPACE)
message (STATUS "NUMPY_INCLUDE: " ${NUMPY_INCLUDE})

This is how I compile

cmake -DPYTHON_EXECUTABLE=/usr/bin/python3 .

Here is my output of cmake, the relevant bits.

-- Found Python: /usr/bin/python3.6 (found version "3.6.9") found components:  Interpreter Development 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so (found version "3.6.9") 
-- NUMPY_INCLUDE: /usr/local/lib/python3.6/dist-packages/numpy/core/include

So far everything is perfect and numpy is found. However, on running make, I get the following

 fatal error: numpy/ndarrayobject.h: No such file or directory
 #include <numpy/ndarrayobject.h>

From what I can see I've covered all bases, yet I'm getting this error. What do I do?

OlorinIstari
  • 537
  • 5
  • 20
  • 2
    Have you tried everything mentioned [here](https://stackoverflow.com/questions/44888925/fatal-error-numpy-arrayobject-h-no-such-file-or-directory)? – forgetso Jul 20 '20 at 17:21
  • Hi @forgetso yes I have. No success. – OlorinIstari Jul 20 '20 at 17:24
  • @ShrutheeshRamanIyer You've already confirmed its in the python includes directory I assume? You also have python-dev installed already as well? – user1238097 Jul 20 '20 at 17:42
  • Hi @user1238097, I'm not sure what you mean exactly. But ```ls -l /usr/include/numpy``` gives the following ```lrwxrwxrwx 1 root root 57 Jul 20 16:32 /usr/include/numpy -> /usr/local/lib/python3.6/dist-packages/numpy/core/include``` So I'm guessing that answers your question? Apologies if it doesnt. And yes, I have python3-dev installed and python-dev as well (though it isnt useful here) – OlorinIstari Jul 20 '20 at 17:44
  • @ShrutheeshRamanIyer if you look inside your ``/usr/local/lib/python3.6/dist-packages/numpy/core/include`` there should be a ndarrayobject.h file present I believe. – user1238097 Jul 20 '20 at 17:47
  • Hi @user1238097 . It wasnt there, it was actually inside ```/usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy```. But when I change everything in the cmake file to this directory, my output for numpy path is still ```/usr/local/lib/python3.6/dist-packages/numpy/core/include```. I have cleared cmake files, cache etc. but not sure what the issue is. – OlorinIstari Jul 20 '20 at 17:56
  • I have copied all the contents in ```/usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy``` to its parent and still not successful. – OlorinIstari Jul 20 '20 at 18:05
  • You've tried resetting the symbolic link as well I assume? – user1238097 Jul 20 '20 at 18:06
  • Can you tell me how to do that? I'm sorry I'm fairly new to this – OlorinIstari Jul 20 '20 at 18:09

0 Answers0