【问题标题】:Changing Python easy_install's default include path更改 Python easy_install 的默认包含路径
【发布时间】:2012-11-22 16:02:32
【问题描述】:

关于 Python 的 setuptools 的问题。我刚刚全新安装了 Mac OS 10.8 并安装了官方 Python 2.7.3 包。安装二进制模块py-bcrypt(或任何其他二进制模块)时,出现以下错误:

bcrypt/bcrypt_python.c:17:10: fatal error: 'Python.h' file not found
#include "Python.h"
         ^
1 error generated.
error: Setup script exited with error: command 'clang' failed with exit status 1

运行 sudo easy_install --verbose py-bcrypt 显示以下对 CLang 的调用:

clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c bcrypt/bcrypt_python.c -o build/temp.macosx-10.8-intel-2.7/bcrypt/bcrypt_python.o

...除了这部分之外很好:

-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 

因为Python.h这里其实存放在-系统库中:/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h

所以最后切入正题:如何更改 setuptools 使用的默认包含路径?

【问题讨论】:

    标签: python macos clang setuptools easy-install


    【解决方案1】:

    在 Ubuntu 中,在 .bashrc.zshrc 中执行此操作将解决问题:

    export C_INCLUDE_PATH=/you_name_it/include/python2.7
    export CPLUS_INCLUDE_PATH=/you_name_it/include/python2.7
    

    它使gcc 能够找到您需要的其他标头,但我不确定它是否适用于clang

    【讨论】:

      【解决方案2】:

      我仍然不知道如何实际执行此操作,但我找到了解决方法。安装 XCode 的命令行工具(首选项 -> 下载 -> 命令行工具)将 Python 标头放在正确的位置。

      【讨论】:

        猜你喜欢
        • 2013-03-13
        • 2013-09-03
        • 1970-01-01
        • 1970-01-01
        • 2011-05-16
        • 2015-10-20
        • 2010-12-06
        • 1970-01-01
        相关资源
        最近更新 更多