brew 在哪里安装 Python 头文件?

Dai*_*air 5 python homebrew cython python-3.x

我正在尝试编译一个简单的“你好,世界!” 在 Cython 中。在一个文件中,我有:

print("Hello, World!")
Run Code Online (Sandbox Code Playgroud)

我跑:

cython hello_world.pyx
Run Code Online (Sandbox Code Playgroud)

获取hello_world.c文件。然后我尝试:

gcc -c hello_world.c
Run Code Online (Sandbox Code Playgroud)

这给出了错误:

fatal error: 'Python.h' file not found
Run Code Online (Sandbox Code Playgroud)

然后我试过这个

gcc -c hello_world.c -framework Python
Run Code Online (Sandbox Code Playgroud)

没用。我已更改include "Python.h"<Python/Python.h>并收到不同的错误:

fatal error: 'longintrepr.h' file not found
Run Code Online (Sandbox Code Playgroud)

无论如何,我想使用 Python3,而不是 Apple 附带的 Python,但我无法弄清楚 Python3 开发头文件的位置。

最终,我希望能够进行编译,hello_world.c以便它在 Python3 解释器中工作。

(我正在使用 brew 的 python3.5.2_1,如果有帮助的话。)

Dai*_*air 1

离开@sr3z的评论,做:

gcc -c random_sum.c -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m
Run Code Online (Sandbox Code Playgroud)

创建random_sum.o.