【问题标题】:python install lxml on mac os 10.10.1在 mac os 10.10.1 上 python 安装 lxml
【发布时间】:2015-08-05 06:19:21
【问题描述】:

我买了一个新的 macbook,我对 mac os 很陌生。但是,我在互联网上阅读了很多关于如何安装废品的信息

我什么都做了,但我在安装 lxml 时遇到了问题

我在终端上试过这个

pip install lxml

很多东西开始下载,很多文字都写在终端上,但我在终端上收到了这个红色的错误消息

1 error generated.

error: command '/usr/bin/clang' failed with exit status 1

----------------------------------------
Cleaning up...
Command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools, tokenize;__file__='/private/var/folders/rd/fxgsy46j3l77f6l9h_hv2fjm0000gn/T/pip_build_mycomputername/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/rd/fxgsy46j3l77f6l9h_hv2fjm0000gn/T/pip-WvDTPQ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/rd/fxgsy46j3l77f6l9h_hv2fjm0000gn/T/pip_build_mycomputername/lxml
Storing debug log for failure in /Users/mycomputername/.pip/pip.log

现在当我用 lxml 调用这个词时,我收到了这个错误消息

ImportError: No module named lxml.html

请问我该怎么办?

欢迎提出任何建议

【问题讨论】:

  • 我认为这是一个重复的问题。你可以在 [这里][1] 找到你的答案。这也可能是help center[2]。 [1]:stackoverflow.com/questions/10666578/…
  • @DarKnight 您提供的链接表明我必须转到 Xcode 然后首选项然后下载并下载命令行工具。但是,我去了那里并没有命令行工具。操作系统和一些 iOS 模拟器需要安装一些更新

标签: python macos python-2.7 scrapy lxml


【解决方案1】:

我遇到了这个问题,我所做的是:

从苹果商店安装了所有的 xcode (2.8GB)。

确保安装成功完成:打开终端并输入

xcode-select -p

你应该得到这样的东西:

/Applications/Xcode.app/Contents/Developer

现在您需要安装命令行工具。尝试在终端上输入gcc,那么有两种可能:或者你会看到一个要求安装工具的窗口,你必须点击install,或者你会收到一条错误消息。

如果您收到错误消息,请不要担心,只需尝试使用此命令安装工具xcode-select --install

之后重启mac,然后像这样重新安装lxml:

pip install lxml

然后尝试再次运行scrapy

如果您在任何其他库上遇到任何其他错误,只需使用 easy_installNOT 使用 pip 轻松重新安装 scrapy

【讨论】:

  • 谢谢!
【解决方案2】:

这可能是因为您在升级后没有重新安装命令行工具。

通常 XCode 应该升级到最新版本(4.4)(我相信当我更新到 10.8 时,我还更新了一大堆其他应用程序,包括 XCode)。更新后您需要重新安装命令行工具。现在可以通过 XCode 中的设置来完成:

转到“首选项 -> 下载”并安装“命令行工具”。

【讨论】:

  • 你为什么要谈论 xcdoe?我从未升级过 Xcode 或 mac os。我一周前刚买了 mac 并安装了 Xcode。
  • 我去了那里,没有命令行工具。操作系统和一些 iOS 模拟器需要安装一些更新
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-11-02
  • 1970-01-01
  • 2015-01-20
  • 2013-04-10
  • 2013-04-17
相关资源
最近更新 更多