python在mac os 10.10.1上安装lxml

Mar*_*oli 8 python macos lxml scrapy python-2.7

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

我做了一切,但我有安装lxml的问题

我在终端试过这个

pip install lxml
Run Code Online (Sandbox Code Playgroud)

并且很多东西开始下载并且许多文本都写在终端上,但我在终端上的红色显示此错误消息

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
Run Code Online (Sandbox Code Playgroud)

现在,当我用scix蜘蛛调用lxml这个词时,我收到了这个错误信息

ImportError: No module named lxml.html
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

任何建议表示赞赏

Pao*_*ang 27

我有这个问题,我做的是:

从Apple商店安装了所有xcode(2.8GB).

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

xcode-select -p
Run Code Online (Sandbox Code Playgroud)

你应该得到这样的东西:

/Applications/Xcode.app/Contents/Developer
Run Code Online (Sandbox Code Playgroud)

现在您需要安装命令行工具.尝试gcc在终端上键入,然后有两种可能性:要么你得到一个窗口要求安装工具而你必须点击install,否则你会收到一条错误信息.

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

之后重新启动mac,然后重新安装lxml,如下所示:

pip install lxml
Run Code Online (Sandbox Code Playgroud)

然后尝试再次进行scrapy

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