【问题标题】:How to make Python.h file work in Ubuntu?如何使 Python.h 文件在 Ubuntu 中工作?
【发布时间】:2021-04-02 07:20:34
【问题描述】:

我在 Ubuntu 机器上,我想在我的 C 代码中使用 python,但是当我包含 Python.h 头文件时,它会显示一个警告: Python.h: No such file or directory

任何方法。我已经尝试过使用:

sudo apt-get install python3-dev 和;

sudo apt-get install python-dev

但它一直显示错误。

【问题讨论】:

    标签: c python-3.8 ubuntu-20.04


    【解决方案1】:

    Python.h 文件不在默认编译器包含路径中。

    pkg-config --cflags python3 的输出添加到编译器命令行。

    现在编译器将知道在哪里可以找到 Python.h(以及它可能具有的任何依赖项)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-26
      • 1970-01-01
      • 1970-01-01
      • 2020-09-24
      • 2020-05-12
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多