python3 build.py build_ext --inplace出错:numpy/arrayobject.h: No such file or directory

在github上chenyuntc/simple-faster-rcnn-pytorch的代码中

运行如下命令:

python3 build.py build_ext --inplace

报错,内容如下:

running build_ext
skipping '_nms_gpu_post.c' Cython extension (up-to-date)
building '_nms_gpu_post' extension
gcc -pthread -B /root/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/root/anaconda3/include/python3.6m -c _nms_gpu_post.c -o build/temp.linux-x86_64-3.6/_nms_gpu_post.o
_nms_gpu_post.c:485:31: fatal error: numpy/arrayobject.h: No such file or directory
#include "numpy/arrayobject.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1

问题原因:

build.py没有包含numpy

解决方法:

修改build.py,import numpy 和include_dirs

import numpy

ext_modules = [Extension("_nms_gpu_post", ["_nms_gpu_post.pyx"],
                  include_dirs=[numpy.get_include()])]

你可能感兴趣的:(问题解决)