在mac osx 升級到 10.10(Yosemite)以后,用pip以及easy_install 安裝python包的時候,如果包需要編譯,就會編譯失敗,錯誤如下:
build/temp.macosx-10.10-x86_64-2.7/greenlet.o -o build/lib.macosx-10.10-x86_64-2.7/greenlet.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
xcode升級到6.1以后python安裝編譯默認clang
當時很困惑為什么在osx中出現python.exe, stackoverflow 上說這只是osx中默認的名稱,沒有實際意義,可忽略
在stackoverflow中給的答案:
可以在 pip install 之前加上 ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future 忽略這個報錯,但是這并沒有解決問題
真正的問題在于python本身的問題,造成不能正常安裝
問題在于:在 Python 的源碼里configure.ac :
????????case $ac_sys_system/$ac_sys_release in
????????...
????????Darwin/*)
????????????????# Use -undefined dynamic_lookup whenever possible (10.3 and later).
????????????????# This allows an extension to be used in any Python
????????????????if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
????????????????then
????????????????????????if test "${enable_universalsdk}"; then
????????????????????????????????LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
????????????????????????fi
????????????????????????LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
????????????????????????LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
????????????????????????BLDSHARED="$LDSHARED"
????????????????else
????????????????????????LDSHARED='$(CC) -bundle'
問題出在?? if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2?
版本10.10 < 10.2 真正的問題來了
解決辦法
首先需要安裝Command-Line Tool(如果沒有安裝 執行命令xcode-select --install 進行安裝)
在python2.7.6以下都有這個問題,最簡單的辦法是安裝2.7.8以上
?