ImportError: No module named spiders

scrapy  入门教程中,有个dirbot 实例,地址:https://github.com/scrapy/dirbot

直接运行会报错:

[@DEV-1-242 dirbot-master]$ scrapy crawl  dmoz

...

    submod = import_module(fullpath)
  File "/data/server/python-2.7.6/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/huangxiaowei/sofast/dirbot-master/dirbot/spiders/dmoz.py", line 1, in
    from scrapy.spiders import Spider
ImportError: No module named spiders


看下源文件:scrapy-0.22/scrapy/spider.py

spiders = ObsoleteClass("""

"from scrapy.spider import spiders" no longer works - use "from scrapy.project import crawler" and then access crawler.spiders attribute"
""")

这个用法已经弃用了,并且提供了说明:

修改一下:

vi dirbot/spiders/dmoz.py

#from scrapy.spiders import Spider
#from scrapy.selector import Selector
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector

from dirbot.items import Website


class DmozSpider(BaseSpider):


解决。。


你可能感兴趣的:(linux服务器)