python - 在 MacOSX 10.7.5 上安装 lxml 时出错 :

标签 python macos lxml pip homebrew

尝试使用 Homebrew 和 pip 在 MacOSX 10.7.5 上安装 lxml 时遇到许多问题。我安装了 Xcode 4.6.3,并安装了命令行工具。这是我的具体步骤:

$ export CC=llvm-gcc-4.2
$ export CXX=llvm-g++-4.2
$ brew install --use--llvm libxml2
$ brew install --use-llvm libxslt
$ sudo pip install lxml

brew 安装成功完成,但 pip install 给出以下错误:

error: command 'cc' failed with exit status 1

完整日志在这里:https://gist.github.com/sloria/5902993

当我尝试使用 easy_install 时:

$ sudo easy_install lxml

我收到一个不同的错误:

error: Setup script exited with error: command 'cc' failed with exit status 1

完整日志在这里:https://gist.github.com/sloria/5903014

这是怎么回事?

最佳答案

尝试使用系统 clang 编译器(无 --use-llvm 标志)并执行 brew doctor 因为您不需要将 sudo 与 pip 一起使用。访问权限可能存在问题,因此 libxml/xmlversion.h 可能无法读取。 你用brew安装了python/pip吗?混合安装brew和未brew安装的应用程序有时会出现问题。

我在我的系统(Mac OSX 10.8.4 和 Xcode 4.6.3)上尝试过:

brew install libxml2
brew install libxslt
pip install lxml

一切都很好。

关于python - 在 MacOSX 10.7.5 上安装 lxml 时出错 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17410664/

相关文章:

python - Python 中的 sum(65537) 有什么问题?

python - 如何在 Docker 容器上运行 Python 服务器

python - 如何通过事件修改 Tkinter Canvas 中的标签

python - 使用来自单独表的 ID 对从表中检索行

ios - 是否有必要将Mac OS X的beta版本用作iOS beta版本的开发环境?

python - OS X 上的Python 的seek() 坏了吗?

c# - 将 Mono 应用程序注册到 OSX 上的 Uri 方案

python - 使用 python/django 安装 lxml 时出现问题

java - Clojure 相当于 Python 的 lxml 库?

python - 文档内架构声明和 lxml