繁体   English   中英

包含 python.h 文件时遇到问题

[英]Having trouble including python.h file

抱歉这个愚蠢的问题,但我试图测试一个 model,它说你可以用 python 3 运行它,但它是用 python 2 编写的。训练代码有效,但测试代码出错。 到目前为止,我已经编辑了 python-config 文件,但是当我运行测试代码时它给了我这个错误:

./include/pybind11/detail/common.h:112:10: fatal error: 'python3 / Python.h'
      file not found
#include <python3 / Python.h>
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.

在 common.h 文件中,我在线阅读,如果我想使用 python 3,我需要以这种方式编辑它:

#include <python3 / Python.h>
#include <python3 / frameobject.h>
#include <python3 / pythread.h>

很抱歉这个愚蠢的问题,但我无法用我的项目做到这一点。

您需要在环境变量中有一个包含 header 文件的 python3 文件夹。 然后 linker 应该可以工作并编译。 但是:pybind应该如下:

#include <Python.h>
#include <frameobject.h>
#include <pythread.h>

您不包含任何更高级别的文件夹。

我希望这会有所帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM