Yocto Honister嵌入librosa模块构建失败,寻求解决方案
在Yocto Honister中添加librosa的构建问题与解决方案
问题描述
我在Yocto Honister(3.4)版本中尝试添加librosa模块,直接在镜像中添加后构建失败,于是改用devtool生成librosa配方(放在rpi-build/workspaces目录),构建有进展但最终因依赖缺失失败。单独执行bitbake librosa提示缺少依赖库,用devtool逐个添加依赖时又遇到一堆问题:比如numba解析错误,还有像lazy_loader生成的配方名是lazy-loader,导致librosa找不到依赖。我知道肯定有更高效的方法,但找不到现成的librosa配方示例,求帮助。
生成的librosa_0.10.1.bb配方代码
# Recipe created by recipetool # This is the basis of a recipe and may need further editing in order to be fully functional. # (Feel free to remove these comments when editing.) SUMMARY = "Python module for audio and music processing" HOMEPAGE = "https://librosa.org" # WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is # your responsibility to verify that the values are complete and correct. LICENSE = "ISC" LIC_FILES_CHKSUM = "file://LICENSE.md;md5=25507c38058deac1239f865af7e6ed72" SRC_URI = "https://files.pythonhosted.org/packages/9a/c4/22a644b91098223d653993388daaf9af28175f2f39073269efa6f7c71caf/librosa-${PV}.tar.gz" SRC_URI[md5sum] = "a5060a34cb7f032d45f88a302fced076" SRC_URI[sha1sum] = "cd51a9861457d600c97faa48c42ce716498a81ab" SRC_URI[sha256sum] = "832f7d150d6dd08ed2aa08c0567a4be58330635c32ddd2208de9bc91300802c7" SRC_URI[sha384sum] = "120d37f4a8f6e8434ecc60d7b050a5445794a1ec7c26a4d0f35bb587e64f771288306ddafaf63f6f615eb4e3a6b4e42a" SRC_URI[sha512sum] = "501e1ce3e01c60e281d57e58f01a6781768d60071878989d346394e07acb799d1d25f380478b4c979a22893dd004e51d3c90eecccb6b1485c9194191f7996791" inherit setuptools3 # The following configs & dependencies are from setuptools extras_require. # These dependencies are optional, hence can be controlled via PACKAGECONFIG. # The upstream names may not correspond exactly to bitbake package names. # # Uncomment this line to enable all the optional features. #PACKAGECONFIG ?= "display docs tests" PACKAGECONFIG[display] = ",,,python3-matplotlib" PACKAGECONFIG[docs] = ",,,python3-ipython python3-matplotlib python3-mir_eval python3-numba python3-numpydoc python3-presets python3-sphinx! python3-sphinx-gallery python3-sphinx-multiversion python3-sphinx_rtd_theme python3-sphinxcontrib-svg2pdfconverter" PACKAGECONFIG[tests] = ",,,python3-matplotlib python3-packaging python3-pytest python3-pytest-cov python3-pytest-mpl python3-resampy python3-samplerate python3-types-decorator" # WARNING: the following rdepends are from setuptools install_requires. These # upstream names may not correspond exactly to bitbake package names. RDEPENDS:${PN} += "python3-audioread python3-decorator python3-joblib python3-lazy-loader python3-msgpack python3-numba numpy python3-pooch python3-scikit-learn python3-scipy python3-soundfile python3-soxr python3-typing-extensions" # WARNING: the following rdepends are determined through basic analysis of the # python sources, and might not be 100% accurate. RDEPENDS:${PN} += "python3-core python3-json python3-shell" # WARNING: We were unable to map the following python package/module # dependencies to the bitbake packages which include them: # matplotlib.axes # matplotlib.cm # matplotlib.collections # matplotlib.colors # matplotlib.lines # matplotlib.markers # matplotlib.path # matplotlib.pyplot # matplotlib.ticker # numpy # numpy.lib.stride_tricks # numpy.typing # pkg_resources # scipy.fftpack # scipy.interpolate # scipy.ndimage # scipy.optimize # scipy.signal # scipy.sparse # scipy.spatial.distance # scipy.stats # sklearn # sklearn.cluster # sklearn.decomposition # sklearn.feature_extraction # sklearn.neighbors
解决方案
- 修正依赖名称映射:devtool生成Python包配方时会自动将下划线转为中划线,比如
lazy_loader对应python3-lazy-loader,确保librosa配方的RDEPENDS里写的是python3-lazy-loader而非python3-lazy_loader。 - 解决Numba构建问题:Numba依赖LLVM,确保你的构建环境包含meta-python层的numba配方,若用devtool生成numba配方,需检查PACKAGECONFIG是否开启llvm相关选项,同时确认LLVM版本与numba兼容(Honister默认LLVM版本需匹配numba 0.10.1的要求)。
- 处理未映射模块:配方中提示的未映射子模块(如numpy、scipy的子模块)均包含在对应主包中,无需额外添加依赖;
pkg_resources属于python3-setuptools,需将其加入RDEPENDS:${PN}。 - 简化PACKAGECONFIG:若不需要文档、测试功能,可注释掉
docs和tests相关的PACKAGECONFIG配置,只保留核心依赖,先确保librosa基础功能能构建成功。 - 迁移配方到正式层:将devtool生成的配方从workspace复制到自定义meta层(如meta-custom),并确保该层已添加到
bblayers.conf,便于长期管理。 - 预构建依赖包:先单独构建librosa的核心依赖,比如执行
bitbake python3-numba python3-scipy python3-scikit-learn,确认这些依赖能正常构建后,再构建librosa,便于定位单个依赖的问题。
内容的提问来源于stack exchange,提问作者A.Joly
相关产品推荐
相关产品推荐

