在Mac OS X上安装libxml2时出现问题

时间:2010-08-17 19:46:41

标签: python c macos libxml2 scrapy

我正在尝试在我的Mac上安装libxml2(OS 10.6.4)。我实际上是想在Python中运行一个Scrapy脚本,这需要我安装Twisted,Zope和现在的libxml2。我已经下载了最新版本(2.7.7,来自xmlsoft.org)并尝试按照这些说明here。总结一下,我尝试了这个命令(在python子目录中):

python setup.py --static-deps --libxml2-version=2.7.7 -- libxslt-version=1.1.24

我最终得到了这个错误:

failed to find headers for libxml2: update includes_dir

有什么想法吗?

我也试过运行这个命令:

./configure --with-python=/System/Library/Frameworks/Python.framework/Versions/2.6/

我收到以下错误:

configure: error: no acceptable C compiler found in $PATH

这是否说明了这种情况?

4 个答案:

答案 0 :(得分:2)

我想出了如何安装libxml2。它花了两个步骤。首先,我没有安装XCode,所以我必须从Apple Developer Tools下载并安装。我认为它已成为OX 10.6.4的标准,但我猜不是。

然后,在libxml2文件夹中,我运行了以下三个命令:

./configure --with-python=/System/Library/Frameworks/Python.framework/Versions/2.3/
make
sudo make install

之后,我切换到libxml2文件夹的Python子目录,并运行通用设置:

python setup.py install

在那之后,一切都准备好了。

答案 1 :(得分:1)

你不应该写--libxml2-version=2.7.7吗?

答案 2 :(得分:1)

我知道这是一个旧线程,但我在使用pip安装依赖时遇到了这个错误。

failed to find headers for libxml2: update includes_dir

我通过使用

重新安装xcode命令行工具来修复它
xcode-select --install

希望这会有助于其他找到这个帖子的人。

答案 3 :(得分:0)

我遇到了与virtualenv相同的问题并解决了它将libxml2的路径添加到全局网站包中安装的自制程序:

echo '/usr/local/opt/libxml2/lib/python2.7/site-packages/'  > /Users/panchicore/.virtualenvs/<virtualenv-name>/lib/python2.7/site-packages/homebrew.pth
相关问题