xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
348 stars 58 forks source link

/home/mona/anaconda3/envs/zephyr/include/xtensor-python/pycontainer.hpp:30:10: fatal error: numpy/arrayobject.h: No such file or directory #295

Closed monajalal closed 1 year ago

monajalal commented 1 year ago

Could you please suggest a fix?

(zephyr) mona@ard-gpu-01:~/zephyr/build$ cmake .. -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  -DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Eigen found (include: /usr/include/eigen3, version: 3.4.0)
-- OpenNI found (version: 1.5.4.0, include: /usr/include/ni, lib: /usr/lib/libOpenNI.so;libusb::libusb)
-- OpenNI2 found (version: 2.2.0.33, include: /usr/include/openni2, lib: /usr/lib/x86_64-linux-gnu/libOpenNI2.so;libusb::libusb)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- Eigen found (include: /usr/include/eigen3, version: 3.4.0)
-- FLANN found (include: /usr/include, lib: /usr/lib/x86_64-linux-gnu/libflann_cpp.so)
-- looking for PCL_COMMON
-- looking for PCL_OCTREE
-- looking for PCL_IO
-- looking for PCL_KDTREE
-- looking for PCL_SEARCH
-- looking for PCL_SAMPLE_CONSENSUS
-- looking for PCL_FILTERS
-- looking for PCL_2D
-- looking for PCL_FEATURES
-- Found pybind11: /home/mona/anaconda3/envs/zephyr/include (found version "2.9.2")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mona/zephyr/build
(zephyr) mona@ard-gpu-01:~/zephyr/build$ make
[ 33%] Building CXX object CMakeFiles/zephyr_c.dir/cpp/oriented_features.cpp.o
In file included from /home/mona/anaconda3/envs/zephyr/include/xtensor-python/pyarray.hpp:22,
                 from /home/mona/zephyr/include/numpy_conversions.h:9,
                 from /home/mona/zephyr/cpp/oriented_features.cpp:20:
/home/mona/anaconda3/envs/zephyr/include/xtensor-python/pycontainer.hpp:30:10: fatal error: numpy/arrayobject.h: No such file or directory
   30 | #include "numpy/arrayobject.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/zephyr_c.dir/build.make:76: CMakeFiles/zephyr_c.dir/cpp/oriented_features.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/zephyr_c.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
monajalal commented 1 year ago

I added the DNUMPY_INCLUDE_DIR in cmake but it was ignored.

not sure how to fix this error

(zephyr) mona@ard-gpu-01:~/zephyr/build$ cmake .. -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  -DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -DNUMPY_INCLUDE_DIR="$(python -c 'import numpy; print("%s/numpy" % numpy.get_include())')"
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Eigen found (include: /usr/include/eigen3, version: 3.4.0)
-- OpenNI found (version: 1.5.4.0, include: /usr/include/ni, lib: /usr/lib/libOpenNI.so;libusb::libusb)
-- OpenNI2 found (version: 2.2.0.33, include: /usr/include/openni2, lib: /usr/lib/x86_64-linux-gnu/libOpenNI2.so;libusb::libusb)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- Eigen found (include: /usr/include/eigen3, version: 3.4.0)
-- FLANN found (include: /usr/include, lib: /usr/lib/x86_64-linux-gnu/libflann_cpp.so)
-- looking for PCL_COMMON
-- looking for PCL_OCTREE
-- looking for PCL_IO
-- looking for PCL_KDTREE
-- looking for PCL_SEARCH
-- looking for PCL_SAMPLE_CONSENSUS
-- looking for PCL_FILTERS
-- looking for PCL_2D
-- looking for PCL_FEATURES
-- Found pybind11: /home/mona/anaconda3/envs/zephyr/include (found version "2.9.2")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mona/zephyr/build
(zephyr) mona@ard-gpu-01:~/zephyr/build$ make
[ 33%] Building CXX object CMakeFiles/zephyr_c.dir/cpp/oriented_features.cpp.o
In file included from /home/mona/anaconda3/envs/zephyr/include/xtensor-python/pyarray.hpp:22,
                 from /home/mona/zephyr/include/numpy_conversions.h:9,
                 from /home/mona/zephyr/cpp/oriented_features.cpp:20:
/home/mona/anaconda3/envs/zephyr/include/xtensor-python/pycontainer.hpp:30:10: fatal error: numpy/arrayobject.h: No such file or directory
   30 | #include "numpy/arrayobject.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/zephyr_c.dir/build.make:76: CMakeFiles/zephyr_c.dir/cpp/oriented_features.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/zephyr_c.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
monajalal commented 1 year ago

This was the fix in CMakeLists.txt:

include_directories(include)
find_package(Python3 3.9 COMPONENTS Interpreter NumPy REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
pybind11_add_module(zephyr_c MODULE cpp/oriented_features.cpp cpp/numpy_conversions.cpp)
target_link_libraries(zephyr_c PRIVATE Eigen3::Eigen ${PCL_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(zephyr_c ${PYTHON_LIBRARIES} Python3::NumPy)