【问题标题】:include Python.h error : initconfig.h not found包括 Python.h 错误:未找到 initconfig.h
【发布时间】:2020-11-22 11:45:11
【问题描述】:
#include <python3.8/Python.h>

我不断收到错误 /usr/include/python3.8/cpython/pystate.h:9:10:致命错误:cpython/initconfig.h:没有这样的文件或目录

9 | #include "cpython/initconfig.h"

最初我只包含 Python.h,但根本找不到。我也在运行 Void Linux,并且已经安装了 python3-devel,如果有区别的话。

【问题讨论】:

  • 您不能也不应该以这种方式包含Python.h。您需要 #include &lt;Python.h&gt; 并将适当的 -I 命令行参数传递给编译器,例如-I/usr/include/python3.8.

标签: c++ c python-3.x


【解决方案1】:

尝试找到您的 Python.h:

gemfield@ThinkPad-X1C:~$ locate Python.h
/home/gemfield/anaconda3/include/python3.7m/Python.h
/home/gemfield/anaconda3/pkgs/python-3.7.6-h0371630_2/include/python3.7m/Python.h
/usr/include/python3.8/Python.h

然后

g++ -I/usr/include/python3.8 ...

【讨论】:

  • 你解释一下会更有帮助。
猜你喜欢
  • 1970-01-01
  • 2016-09-17
  • 1970-01-01
  • 2015-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多