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

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

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

2. python -c “import numpy; print(numpy.get_include())”

strong@foreverstrong:~$ python -c "import numpy; print(numpy.get_include())"
/usr/local/lib/python2.7/dist-packages/numpy/core/include
strong@foreverstrong:~$ 
strong@foreverstrong:~$ python-config --prefix
/usr
strong@foreverstrong:~$ 
strong@foreverstrong:~$ python-config --includes
-I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7
strong@foreverstrong:~$ 

numpy/arrayobject.h 文件是 NumPy 的头文件。
python -c "import numpy; print(numpy.get_include())" 找不到的话,需要安装 NumPy。
python -c "import numpy; print(numpy.get_include())" 找到的话,在使用 numpy/arrayobject.h 文件的工程中,修改 Makefile 搜索路径。

3. NPINCLUDE

# Python version
PYTHON_VERSION=2


ifeq ($(PYTHON_VERSION), 2)
PINCLUDE=$(shell python-config --includes)
COMMON+= $(PINCLUDE)

NPINCLUDE=$(shell python -c "import numpy; print(numpy.get_include())")
COMMON+= -I$(NPINCLUDE)

PLIB=$(shell python-config --libs)
LDFLAGS+= $(PLIB)
endif
# Python version
PYTHON_VERSION=3


ifeq ($(PYTHON_VERSION), 3)
PINCLUDE=$(shell python3-config --includes)
COMMON+= $(PINCLUDE)

NPINCLUDE=$(shell python3 -c "import numpy; print(numpy.get_include())")
COMMON+= -I$(NPINCLUDE)

PLIB=$(shell python3-config --libs)
LDFLAGS+= $(PLIB)
endif

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值