安装Scrapy

1.用easy_install安装pip,pip 是对 easy_install的升级。

2.sudo pip install scrapy时会报错

#include "libxml/xmlversion.h"
    ^
    1 error generated.
    error: command 'cc' failed with exit status 1

注:没有命令行开发工具 执行xcode-select --install ;而我有但是目录不对,要改变目录sudo xcode-select --switch /Applications/Xcode.app

3.解决办法

sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2/libxml:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include pip install lxml

4.在执行sudo pip install scrapy,安装成功了。

5.因为版本问题报错,自己找了好久,终于在评论里看到了。

HappyMan:~ maodenden$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrapy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 48, in <module>
    from scrapy.spiders import Spider
  File "/Library/Python/2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
    from scrapy.http import Request
  File "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 12, in <module>
    from scrapy.http.request.rpc import XmlRpcRequest
  File "/Library/Python/2.7/site-packages/scrapy/http/request/rpc.py", line 7, in <module>
    from six.moves import xmlrpc_client as xmlrpclib
ImportError: cannot import name xmlrpc_client

出现报错可以试试先卸载再安装0.24的版本
sudo pip uninstall scrapy
sudo pip install scrapy==0.24.2

posted @ 2015-09-13 10:49  解忧杂货店  阅读(404)  评论(0编辑  收藏  举报