2016-09-11 93 views
2

我想编译一个简单的“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,是否有帮助。)

+0

你是否试过简单的'whereis'你正在使用的python可执行文件? IIRC的路径是'/ usr/local/bin'的行,并在'/ usr/local/include'中安装头文件。不幸的是,我没有mac了,所以我无法检查 – UnholySheep

+0

在Linux上,您需要安装python-dev。酿造可能也是如此。 – zmbq

+0

检查它是否在/usr/local/Cellar/python//Frameworks/Python.framework/Versions/ /include/python /Python.h – sr3z

回答

0

从@ sr3z的评论都会响起来,这样做的:

gcc -c random_sum.c -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m 

创建random_sum.o

0

当前是/usr/local/Frameworks/Python.framework/Headers