【问题标题】:Error while install lxml安装 lxml 时出错
【发布时间】:2015-01-30 17:45:13
【问题描述】:

我正在尝试使用 pip 安装 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

知道发生了什么吗?

【问题讨论】:

    标签: python macos lxml


    【解决方案1】:

    根据Xcode 5 Release Notes

    Xcode 5.1 中的 Apple LLVM 编译器将无法识别的命令行选项视为错误。在构建 Python 原生扩展和 Ruby Gems 时发现了这个问题,其中当前指定了一些无效的编译器选项。

    ...

    要解决此问题,请设置 ARCHFLAGS 环境变量以将错误降级为警告。例如,您可以安装 Python 原生扩展:

    $ 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
    

    【讨论】: