【问题标题】:Cython code : Python.h no such file or directoryCython 代码:Python.h 没有这样的文件或目录
【发布时间】:2016-06-04 22:07:16
【问题描述】:

当我使用 cython3 从 python3 代码生成 C 代码并尝试使用 gcc 编译生成的代码时,我收到此错误:test.c:4:20: fatal error: Python.h: Aucun fichier ou dossier de ce type

我在网上查看了这个错误,所有的答案都是关于安装 python2-devpython3-dev ,但我已经在我的电脑上安装了这两个。我不仅有这两个,还有python3.4-devpython3.5-dev

那么谁能给我解决这个错误的方法。

PS:我使用的是 Ubuntu 15.10,Linux 版本 > 4。

【问题讨论】:

  • apt-cache policy python-dev 说什么?

标签: python c linux ubuntu cython


【解决方案1】:

您应该使用适当的路径进行编译,像这样...

$ gcc -o test test.c `pkg-config --cflags --libs python3`

之前发生的事情是您没有包含适当的包含路径(由pkg-config --cflags 检索)和库/链接路径(由pkg-config --libs 检索)。包括这两者,你的程序应该能够编译和链接。

【讨论】:

猜你喜欢
  • 2016-04-12
  • 2012-06-17
  • 2021-08-27
  • 2017-12-13
  • 2021-02-26
  • 2021-09-19
相关资源
最近更新 更多