包含 Python.h 错误:找不到 initconfig.h

Jus*_*ike 6 c c++ python-3.x

#include <python3.8/Python.h>
Run Code Online (Sandbox Code Playgroud)

我不断收到错误 /usr/include/python3.8/cpython/pystate.h:9:10: fatal error: cpython/initconfig.h: No such file or directory

9 | #include "cpython/initconfig.h"
Run Code Online (Sandbox Code Playgroud)

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

gem*_*eld 4

尝试找到你的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
Run Code Online (Sandbox Code Playgroud)

然后

g++ -I/usr/include/python3.8 ...
Run Code Online (Sandbox Code Playgroud)

  • 如果你解释一下会更有帮助。 (6认同)