更改Python easy_install的默认包含路径

时间:2012-12-04 22:13:23

标签: python macos clang setuptools easy-install

关于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实际存储在 non - 系统库中:/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h

所以最后要说明一点:如何更改setuptools使用的默认包含路径?

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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