我买了一台新的 macbook,我对 mac os 很陌生。但是,我在互联网上阅读了很多关于如何安装 scrap 的信息
我什么都做了,但我在安装 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
请问我该怎么办?
感谢任何建议
最佳答案
我遇到了那个问题,我所做的是:
从苹果商店安装了所有 xcode (2.8GB)。
确保安装成功:打开终端并输入
xcode-select -p
你应该得到这样的东西:
/Applications/Xcode.app/Contents/Developer
现在您需要安装命令行工具。尝试在终端上输入 gcc
,然后有两种可能性:要么你会看到一个要求安装工具的窗口,你必须点击 install
,否则你会得到一条错误消息。
如果您收到错误消息,请不要担心,只需尝试使用此命令安装工具 xcode-select --install
之后重新启动 mac,然后像这样重新安装 lxml:
pip install lxml
然后尝试再次运行scrapy
如果您在任何其他库上遇到任何其他错误,只需使用 easy_install 轻松地重新安装 scrapy 而不要使用 pip
关于python 在 mac os 10.10.1 上安装 lxml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30410030/