【问题标题】:How to install the Python development headers on Mac OS X?如何在 Mac OS X 上安装 Python 开发头文件?
【发布时间】:2013-04-10 16:24:55
【问题描述】:

对于使用 Boost.Python 的项目(请参阅 this other question),我需要包含例如的 Python 开发标头。 pyconfig.h

这些显然从我的系统中丢失。我已经通过 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

我也希望通过 Homebrew 获取标头,但我找不到它们的包。

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

我有哪些安装这些标头的选项?有 Homebrew 包吗?

【问题讨论】:

    标签: python macos header homebrew


    【解决方案1】:

    最新的 Python 3 公式链接了一个名为 python3-config 的程序。您可以使用它来查找这样的标题:

    python3-config --include

    在我的机器上,这个输出:

    -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
    

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

    对于 Python 2,有一个名为 python-config 的等效程序。

    【讨论】:

    • 按照这些思路,最新的brew install smpeg --HEAD smpeg 似乎在寻找这个python-config,但是在virutalenv 的文本上下文中,构建系统找不到它。我将正确的 python3-config 符号链接到我的 virtualenv 的 bin/python-config,事情变得更好了。
    • 嗯...我想知道这是否是一个错误。也许你可以打开一个问题here
    • 如果你在任何虚拟环境中,python3-config 应该会给你想要的结果。您可以使用 which python3-config 验证路径
    【解决方案2】:

    这些是您要查找的标题吗:

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

    【讨论】:

    • 可能是的,它们包括缺少的pyconfig.h。我会尝试将此作为包含路径告诉我的 gcc。
    • 它们没有链接到 /usr/local/include/python3.3 有什么原因吗?它们很难找到,一旦新版本的 python 发布(例如 3.3.1),路径就会停止工作..
    猜你喜欢
    • 2012-03-31
    • 1970-01-01
    • 2013-04-17
    • 2011-04-07
    • 2011-11-29
    • 2013-12-03
    • 2010-11-15
    相关资源
    最近更新 更多