Python.h header file missing on Mac OS X 10.6

后端 未结 4 818
-上瘾入骨i
-上瘾入骨i 2020-12-05 21:04

I\'m trying to access a shared C library in Python with ctypes on Mac OS X 10.6.8 with Python 2.7.4. To do this, I need to #include

相关标签:
4条回答
  • 2020-12-05 21:24

    Another way is to add `python-config --include` to the gcc call. It will expand to -I/usr/..., so

    gcc -shared -o sample.so sample.c `python-config --include`
    

    Also other options can be retrieved, such as `python-config --cflags --ldflags`.

    0 讨论(0)
  • 2020-12-05 21:27

    In case you have installed Python using Brew, it may be worthwhile to check the location of where your headers are. Try I/usr/local/Cellar/python/...

    0 讨论(0)
  • 2020-12-05 21:32

    I'm not sure about 10.6.8, but Python.h should be in

    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
    

    if you installed the official python.org binary. Try adding

    -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
    

    to your gcc command and see if that works.

    0 讨论(0)
  • 2020-12-05 21:41

    Python is a framework on Mac OS X so you need to,

    #include <Python/Python.h>
    

    You also need to call gcc with the -framework argument to actually do anything inside C,

    gcc -shared -o sample.so sample.c -framework Python
    
    0 讨论(0)
提交回复
热议问题