python - 将 <Python.h> 包含到 makefile.am

标签 python c++ c python-2.7 makefile

对于这个新手问题,我深表歉意。我目前正在寻找将一个小的 python 代码嵌入到一个主要的 C 代码中。建议使用#include <Python.h>在标题处。我已经这样做了,我的 Ubuntu12-0.4 机器也有 python-dev安装。

通过运行 locate Python.h , 我得到了 /usr/include/python2.7/Python.h .

但是,当我将 Python.h 包含到我的 C 程序中时,它仍然给我 fatal error: python.h: No such file or directory .

所以 Python.h 还没有包含在 Makefile 中。但我不知道该怎么做。查看我的包裹 list ,我有:Makefile.am , Makefile.in , 和 Makefile .


在 Makefile.am 中:

ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = MIGRATION README.rst libmodbus.spec
SUBDIRS = src doc tests

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libmodbus.pc

在 Makefile.in 中, 第一行说

# Makefile.in generated by automake 1.14.1 from Makefile.am.

我还应该包括 Makefile.in 的完整描述吗?到这里?我不确定我应该如何进行。

最佳答案

我有同样的错误,试试这个:

gcc -I/usr/include/python2.7 yoursource.c -o yourprogram

此解决方案来自: Can't find Python.h file on CentOS

关于python - 将 <Python.h> 包含到 makefile.am,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28254733/

相关文章:

python - 为什么 Tensorflow 转置在特定场景下失败?

java - 隐藏在我需要学习的东西之外?

python - json.loads() 解析从 node.js 接收的 JSON 对象时给出 UnicodeEncodeError

python - 云中的 OpenCV

python - 在 iPython-QtConsole (Anaconda) 中键入 import copy 时出现奇怪的错误

c++ - 将多种类型分配给 Bison 中的非终端

c++ - 使用struct中的指针来更改数据

c++ - 从 fstream 对象读取括号。 C++

c - C 中删除数组中的空格?

c - 如何用C语言从本地服务器发送HTTP协议(protocol)