Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Distutils可以';我找不到Python.h_Python_Gcc_Distutils_Python C Extension - Fatal编程技术网

Distutils可以';我找不到Python.h

Distutils可以';我找不到Python.h,python,gcc,distutils,python-c-extension,Python,Gcc,Distutils,Python C Extension,我有一个带有扩展部分的distutils设置脚本,它看起来像这样: from distutils.core import setup, Extension my_module = Extension('my_module', sources = ['my_file.c', 'my_other_file.c']) setup (name = 'my_module', version = '1.0', description = 'My

我有一个带有扩展部分的distutils设置脚本,它看起来像这样:

from distutils.core import setup, Extension

my_module = Extension('my_module',
                sources = ['my_file.c', 'my_other_file.c'])

setup (name = 'my_module',
       version = '1.0',
       description = 'My module',
       ext_modules = [my_module])
在我的Mac电脑上运行
setup.py build
很好。当我移动到Debian机器时,它会失败:

error: Python/Python.h: No such file or directory
我已经安装了
python2.6
python2.6-dev
,文件位于
/usr/include/python2.6

它为问题文件执行的命令:

gcc-pthread-fno严格别名-DNDEBUG-g-fwrapv-O2-Wall-Wstrict原型-fPIC-I/usr/include/python2.6-c my_module.c-o-build/XYZ/my_module.o

因此,它正在传递头文件的位置

Mac与Linux环境之间唯一明显的区别是gcc-4.2与gcc-4.4以及Python2.7与Python2.6

想法

编辑:

在相关的C文件中:

#include <Python/Python.h>
#include <Python/structmember.h>
#包括
#包括

可能在您的模块中,您需要
包含“Python.h”
而不是
“Python/Python.h”

或者您可以尝试导出include path,然后尝试使用gcc或g++再次编译

export C_INCLUDE_PATH=/usr/include/python2.6:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include/python2.6:$CPLUS_INCLUDE_PATH

在我的例子中,我丢失了python3 dev,
sudo apt get install python3 dev
修复了它。

你能试着将这两行代码改成只包含“Python.h”
并再次编译吗?我做了,看起来它修复了它。你知道为什么它会在mac上使用“Python/Python.h”而不是在linux上吗?我想这只是因为目录结构根据安装选项不同,linux在/usr/include/python2.6/下有Python.h,但mac可能在/usr/include/Python/Python.h下,但我没有mac,所以很难说我的假设正确与否。啊,是的,有不同的方法可以让Mac使用Python!我认为它使用的是“/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h”(在/usr/include中也有版本),正好相反!原始文件具有
Python/Python.h
(请参见编辑)。我把它改为只包含
。看起来这在两种平台上都有效。有什么评论吗?+1那是完美的*你能给我指一种“GCC配置备忘单”或类似的东西吗?