我想安装Lxml,这样我就可以安装Scrapy了。

当我更新我的Mac今天,它不让我重新安装lxml,我得到以下错误:

In file included from src/lxml/lxml.etree.c:314:
/private/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
         ^
1 error generated.
error: command 'cc' failed with exit status 1

我尝试使用brew安装libxml2和libxslt,两者都安装好了,但我仍然无法安装lxml。

上次安装时,我需要在Xcode上启用开发人员工具,但由于它更新到Xcode 5,它不再给我这个选项了。

有人知道我要做什么吗?


当前回答

你可以通过在命令行上运行这个命令来解决你的问题:

 STATIC_DEPS=true pip install lxml

这对我很有帮助。 文档说明

其他回答

不幸的是,xcode-select -install不适合我,因为我已经有了最新的版本。

这很奇怪,但我通过打开XCode并接受条款和条件解决了这个问题。重新运行pip install lxml之后没有返回错误。

在咬着牙撕扯头发之后,我用pip卸载了Xcode,然后运行:

easy_install lxml

一切都很好。

你应该安装或升级Xcode的命令行工具。 在终端试试这个:

xcode-select --install

OSX 10.9.2

sudo env ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future STATIC_DEPS=true pip install lxml

皮普没有为我工作。我去了 https://pypi.python.org/pypi/lxml/2.3 下载macosx .egg文件:

https://pypi.python.org/packages/2.7/l/lxml/lxml-2.3-py2.7-macosx-10.6-intel.egg#md5=52322e4698d68800c6b6aedb0dbe5f34

然后使用命令行easy_install安装.egg文件。