我想编译一个简单的“Hello,World!”在Cython中。在文件中,我有:brew在哪里安装Python头文件?
print("Hello, World!")
我运行:
cython hello_world.pyx
要获得hello_world.c
文件。然后我尝试:
gcc -c hello_world.c
这给错误:
fatal error: 'Python.h' file not found
然后我试图this:
gcc -c hello_world.c -framework Python
没有工作。我已经改变include "Python.h"
到<Python/Python.h>
,并得到了不同的错误:
fatal error: 'longintrepr.h' file not found
无论如何,我想用Python3,而不是苹果的Python附带的,但我无法揣摩出Python3开发头的位置。
最终,我希望能够编译hello_world.c
,以便它在Python3解释器中工作。
(我用BREW的python3.5.2_1,是否有帮助。)
你是否试过简单的'whereis'你正在使用的python可执行文件? IIRC的路径是'/ usr/local/bin'的行,并在'/ usr/local/include'中安装头文件。不幸的是,我没有mac了,所以我无法检查 – UnholySheep
在Linux上,您需要安装python-dev。酿造可能也是如此。 – zmbq
检查它是否在/usr/local/Cellar/python//Frameworks/Python.framework/Versions/ /include/python /Python.h –
sr3z