[英]fatal error: numpy/arrayobject.h: No such file or directory #include "numpy/arrayobject.h" in google colab
[英]Include numpy's arrayobject.h into bitbake recipe - how to fix installation order?
我的 python 包依賴於 ac 擴展,而 ac 擴展又使用了 numpy 的arrayobject.h
。 我在沒有包的情況下構建了映像並確認此文件存在: /usr/lib/python3.5/site-packages/numpy/core/include
。 我還修補了 distutil 的setup.py
如下:
diff --git a/setup.py b/setup.py
index 99dcc2a..ecb2675 100644
--- a/setup.py
+++ b/setup.py
@@ -11,8 +11,12 @@ building_wheel = bool(sys.argv[1].strip() == 'bdist_wheel')
def get_numpy_include():
- import numpy
- return numpy.get_include()
+ try:
+ import numpy
+ return numpy.get_include()
+
+ except ImportError:
+ return '/usr/lib/python3.5/site-packages/numpy/core/include'
def get_build_include(lib_name):
@@ -106,6 +110,7 @@ setup(
name='ringnes.ringbuffer_base',
sources=sources,
libraries=clibraries,
+ include_dirs=[get_numpy_include()],
define_macros=[(sensor_type, 0)]),
Extension(
name='ringnes.mseed_ext',
因此,該目錄是硬編碼的,但我必須捕獲導入異常這一事實表明,numpy 尚不可用,因此也缺少arrayobject.h
。
所以問題是:在 bb 在這個食譜中起作用之前,我如何確保 numpy 存在?
這是(重要的部分)食譜。 注意DEPENDS
(認為DEPENDS
足夠了):
inherit setuptools3
# Experimenting with CFLAGS
# TARGET_CFLAGS_append = " -I/usr/lib/python3.5/site-packages/numpy/core/include"
LAYERDEPENDS += " \
meta-openembedded \
meta-python \
"
DEPENDS += " \
python3-numpy \
"
RDEPENDS_${PN} += " \
python3-numpy \
python3-scipy \
python3-cryptography \
python3-smbus \
python3-psutil \
python3-hbmqtt \
"
RRECOMMENDS_${PN} += " \
python3-wifi \
"
簡單的答案是指定對本機(目標)numpy 的依賴:
DEPENDS += " \
python3-numpy-native \
"
我還沒有確認一切都構建到最后,但至少arrayobject.h
現在似乎可用。
編輯:現在一切似乎都正常。 添加python3-numpy-native
也使 numpy 的補丁過時了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.