在OSX 10.9中安装lxml

时间:2014-04-14 09:32:15

标签: python macos lxml osx-mavericks

我在我的小牛机器上安装lxml时遇到问题。

我通过使用

安装prebuild二进制文件尝试了所有可能性
  • normal pip
  • static deps

和建筑

  • 正常模型中的当前版本
  • 包含静态deps的当前版本
  • 正常模式下的旧版
  • 带有静态代码的旧版本

并始终以此错误结束。

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1

这里有详细的消息

copying /Users/mangoreader/work/lxml-3.3.4/build/tmp/libxml2/include/libxslt/xsltutils.h -> build/lib.macosx-10.9-intel-2.7/lxml/includes/libxslt
running build_ext
building 'lxml.etree' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -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 -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/Users/mangoreader/work/lxml-3.3.4/build/tmp/libxml2/include -I/Users/mangoreader/work/lxml-3.3.4/build/tmp/libxml2/include/libxml2 -I/Users/mangoreader/work/lxml-3.3.4/build/tmp/libxml2/include/libxslt -I/Users/mangoreader/work/lxml-3.3.4/build/tmp/libxml2/include/libexslt -I/Users/mangoreader/work/lxml-3.3.4/src/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.9-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1

此外,当我尝试安装cython时,我收到同样的错误

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

详细记录

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -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 -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c /private/var/folders/1z/7lv1qq457qxbhkgpt1fk9sdc0000gn/T/pip_build_mangoreader/cython/Cython/Plex/Scanners.c -o build/temp.macosx-10.9-intel-2.7/private/var/folders/1z/7lv1qq457qxbhkgpt1fk9sdc0000gn/T/pip_build_mangoreader/cython/Cython/Plex/Scanners.o

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/1z/7lv1qq457qxbhkgpt1fk9sdc0000gn/T/pip_build_mangoreader/cython/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/1z/7lv1qq457qxbhkgpt1fk9sdc0000gn/T/pip-0akrMB-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/1z/7lv1qq457qxbhkgpt1fk9sdc0000gn/T/pip_build_mangoreader/cython
Storing debug log for failure in /Users/mangoreader/Library/Logs/pip.log

我完全被击中了。这似乎与版本与gcc或libxml的冲突有关。但我无法弄清楚是什么。任何帮助非常感谢。

解决

根据此SO clang error: unknown argument: '-mno-fused-madd' (python package installation failure),可以通过设置以下env变量来修复此问题

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

1 个答案:

答案 0 :(得分:0)

我确信你已将其整理出来,但万一其他人需要它,请安装XCode和命令行工具,然后运行

pip install lxml

它会起作用,可能需要一点时间。