Python: pybind11:fatal error: Python.h: No such file or

文章介绍了Pybind11在实现C++11与Python无缝互操作时可能遇到的版本兼容问题,特别是Python模块导入错误和找不到Python头文件的问题。解决方案包括更新pybind11到最新版本和安装python3-devel或platform-python-devel依赖以包含Python.h。此外,还提供了一个应用示例链接,展示如何使用Lief进行编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

简介

https://pybind11.readthedocs.io/en/stable/index.html
Seamless operability between C++11 and Python; 实现C++11和Python的无缝互操作。很厉害。

版本兼容问题的引用错误

https://mzhan017.blog.csdn.net/article/details/128826022
Python: ImportError: dynamic module does not define module export function (PyInit_name;需要下载新版本pybind11进行项目的编译。

自身编译错误

/home/mzhan017/aviso-fes-main/third_party/pybind11/include/pybind11/detail/common.h:112:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
这个错误的解决方法之一:
dnf install python3-devel;
这个依赖:platform-python-devel,这个包里包含有Python.h文件
https://centos.pkgs.org/8-stream/centos-appstream-aarch64/platform-python-devel-3.6.8-51.el8.aarch64.rpm.html

这里要说明一下,centos7和centos8,这个文件所在的rpm包不同。
https://centos.pkgs.org/7/centos-aarch64/python3-devel-3.6.8-17.el7.aarch64.rpm.html

所以,pybind11的编译需要platform-python-devel做支持。还是要安装python3-devel。

python3-devel-3.7.4-8.se.01.ky10.aarch64.rpm

应用举例

https://lief-project.github.io/doc/latest/compilation.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

mzhan017

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值