安装lxml时出错

问题描述:

我正试图用pip安装lxml。运行我的剧本时,我收到这个初始误差:安装lxml时出错

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library? 

快速搜索上面的错误(如here)透露我需要安装LXML。

尝试安装LXML我收到以下错误:

clang: error: unknown argument: '-mno-fused-madd' 

error: command 'cc' failed with exit status 1 

任何想法是怎么回事?

根据Xcode 5 Release Notes

The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.

...

To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning. For example, you can install a Python native extension with:

$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future \ 
    easy_install ExtensionName 

设置以下环境变量安装lxml前:

export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future