我有需要跨平台编译的python扩展代码,为此,我需要能够找到python include文件夹。在Linux和Mac上,我可以做python-config --include,它给了我类似-I/Library/Frameworks/Python.framework/Versions/6.3/include/python2.6的东西。这很好,除了我的Windows python发行版没有python-config。有没有一种简单的方法,通过python代码,找到它认为的include文件夹的位置?对于numpy,此代码段完成以下工作:
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()python include文件夹有没有类似的方法?
发布于 2011-04-11 03:54:14
您可以尝试这样做:
>>> from distutils import sysconfig
>>> sysconfig.get_python_inc()
'/usr/include/python2.6'
>>> sysconfig.get_python_inc(plat_specific=True)
'/usr/include/python2.6'注意:我通过查看python-config源代码发现了这一点。
https://stackoverflow.com/questions/5614192
复制相似问题