python在Mac OS 10.10.1上安装lxml

马可·迪纳佐利(Marco Dinatsoli)

我买了一台新的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调用scrapy spider这个词时,我收到了此错误消息

ImportError: No module named lxml.html

我该怎么办?

任何建议表示赞赏

保罗·朗

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

从Apple Store安装了所有xcode(2.8GB)。

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

xcode-select -p

你应该得到这样的东西:

/Applications/Xcode.app/Contents/Developer

现在您需要安装命令行工具。尝试gcc在终端上键入,则有两种可能:或者出现一个要求安装工具的窗口,而必须单击install,或者出现错误消息。

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

之后,重新启动mac,然后再次像下面这样重新安装lxml:

pip install lxml

然后尝试再次运行

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章