如何在 Mac OS X 上安装 Python 开发头文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15931331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 21:24:29  来源:igfitidea点击:

How to install the Python development headers on Mac OS X?

pythonmacosheaderhomebrew

提问by clstaudt

For a project using Boost.Python (see this other question) I need the Python development headers containing e.g. pyconfig.h.

对于使用 Boost.Python 的项目(请参阅其他问题),我需要包含例如pyconfig.h.

These are apparently missing from my system. I've installed Python 3 via Homebrew:

这些显然从我的系统中丢失了。我已经通过 Homebrew 安装了 Python 3:

cls ~ $ brew info python3
python3: stable 3.3.0
http://www.python.org/
Depends on: pkg-config, readline, sqlite, gdbm
/usr/local/Cellar/python3/3.2.3 (4420 files, 78M)
/usr/local/Cellar/python3/3.3.0 (4843 files, 93M) *
https://github.com/mxcl/homebrew/commits/master/Library/Formula/python3.rb

I would prefer getting the headers via Homebrew, too, but I cannot find a package for them.

我也更喜欢通过 Homebrew 获取标题,但我找不到它们的包。

cls ~ $ brew search python-dev
No formula found for "python-dev". Searching open pull requests...

What are my options for installing these headers? Is there a Homebrew package?

安装这些标头有哪些选择?有 Homebrew 包吗?

采纳答案by gatto

Are these the headers you are looking for:

这些是您正在寻找的标题:

Cellar/python3/3.3.0//Frameworks/Python.framework/Versions/3.3/include/python3.3m/

回答by daviewales

The latest Python 3 formula links a program called python3-config. You can use it to find the headers like this:

最新的 Python 3 公式链接了一个名为python3-config. 您可以使用它来查找标题,如下所示:

python3-config --include

python3-config --include

On my machine, this outputs:

在我的机器上,这输出:

-I/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/include/python3.3m -I/usr/local/Cellar/python3/3.3.4/Frameworks/Python.framework/Versions/3.3/include/python3.3m

You may need to brew update && brew rm python3 && brew install python3to enable this.

您可能需要brew update && brew rm python3 && brew install python3启用此功能。

There is an equivalent program called python-configfor Python 2.

有一个等效的程序称为python-configPython 2。