关于 Python 的设置工具的问题。我刚刚全新安装了 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 使用的默认包含路径?
请您参考如下方法:
在 Ubuntu 中,在 .bashrc 或 .zshrc 中执行此操作可以解决问题:
export C_INCLUDE_PATH=/you_name_it/include/python2.7
export CPLUS_INCLUDE_PATH=/you_name_it/include/python2.7
它使 gcc 能够找到您需要的其他 header ,但我不确定它是否适用于 clang。
