Joe*_*Joe 5 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 module',
ext_modules = [my_module])
Run Code Online (Sandbox Code Playgroud)
setup.py build
在我的Mac上运行正常.当我移动到Debian机器时,它失败了:
error: Python/Python.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我python2.6
和python2.6-dev
安装,并且该文件存在/usr/include/Python2.6
.
它为问题文件执行的命令:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c my_module.c -o -build/XYZ/my_module.o
所以它传递的是头文件的位置.
Mac与Linux环境之间唯一明显的区别是gcc-4.2 vs gcc-4.4和Python 2.7 vs Python 2.6
想法?
编辑:
在有问题的C文件中:
#include <Python/Python.h>
#include <Python/structmember.h>
Run Code Online (Sandbox Code Playgroud)
可能在你的模块中,你需要include "Python.h"
代替"Python/Python.h"
吗?
或者您可以尝试导出包含路径,并尝试使用gcc或g ++再次编译?
export C_INCLUDE_PATH=/usr/include/python2.6:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include/python2.6:$CPLUS_INCLUDE_PATH
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11657 次 |
最近记录: |