/home/syl/software/opencv/modules/python/src2/cv2.cpp:33:10: fatal error: numpy/ndarrayobject.h: No such file or directory
#include <numpy/ndarrayobject.h>
看到网上有说解决方法是:
sudo apt-get install python-numpy
试了下,不行,然后自己检查了一下代码,发现是python2.7的安装路径问题
所以,修改opencv的cmake编译选项即可。
原来:
-DPYTHON2_NUMPY_INCLUDE_DIRS=/usr/lib/python2.7/dist-packages/numpy/core/include/ \
-DPYTHON2_PACKAGES_PATH=/usr/lib/python2.7/dist-packages \
修改成:
-DPYTHON2_NUMPY_INCLUDE_DIRS=/usr/local/lib/python2.7/dist-packages/numpy/core/include/ \
-DPYTHON2_PACKAGES_PATH=/usr/local/lib/python2.7/dist-packages \
这个问题在后续Dynaslam的编译中也会出现,需要把CMakeList里面的python路径修改一下。
原来:
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/include
${EIGEN3_INCLUDE_DIR}
${Pangolin_INCLUDE_DIRS}
/usr/include/python2.7/
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/
${Boost_INCLUDE_DIRS}
)
修改成:
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/include
${EIGEN3_INCLUDE_DIR}
${Pangolin_INCLUDE_DIRS}
/usr/include/python2.7/
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy
${Boost_INCLUDE_DIRS}
)
然后又有点奇怪,编译好docker之后,重新加载,发现自己修改路径的方法居然不行了,又只能换了种方法解决这个问题。
rm -rf /usr/include/numpy && \
ln -s /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy /usr/include/numpy