1

我从github下载了scrapy-redis并按照说明运行它,但它失败并给出了这个错误:

2013-01-04 17:38:50+0800 [-] ERROR: Unhandled error in Deferred:
2013-01-04 17:38:50+0800 [-] Unhandled Error
        Traceback (most recent call last):
          File "/usr/local/lib/python2.7/dist-packages/Scrapy-0.16.3-py2.7.egg/scrapy/cmdline.py", line 138, in _run_command
            cmd.run(args, opts)
          File "/usr/local/lib/python2.7/dist-packages/Scrapy-0.16.3-py2.7.egg/scrapy/commands/crawl.py", line 44, in run
            self.crawler.crawl(spider)
          File "/usr/local/lib/python2.7/dist-packages/Scrapy-0.16.3-py2.7.egg/scrapy/crawler.py", line 47, in crawl
            return self.engine.open_spider(spider, requests)
          File "/usr/local/lib/python2.7/dist-packages/Twisted-12.2.0-py2.7-linux-i686.egg/twisted/internet/defer.py", line 1187, in unwindGenerator
            return _inlineCallbacks(None, gen, Deferred())
        --- <exception caught here> ---
          File "/usr/local/lib/python2.7/dist-packages/Twisted-12.2.0-py2.7-linux-i686.egg/twisted/internet/defer.py", line 1045, in _inlineCallbacks
            result = g.send(result)
          File "/usr/local/lib/python2.7/dist-packages/Scrapy-0.16.3-py2.7.egg/scrapy/core/engine.py", line 218, in open_spider
            scheduler = self.scheduler_cls.from_crawler(self.crawler)
        exceptions.AttributeError: type object 'Scheduler' has no attribute 'from_crawler'

如何处理?谢谢。

4

2 回答 2

6

问题是scrapy-redis 是一年前使用scrapy 0.13 编写的。scrapy 的当前版本是 0.17,如果您将当前的 scrapy/core/engine.py源代码与去年的版本进行比较,您可以看到导致错误的行是在这两个版本之间的某个时间点添加的(在事实上,它是在 2012 年8 月 21 日添加的)

简而言之,错误的发生是因为scrapy-redis 不再与当前版本的scrapy 兼容。可能值得联系开发人员询问他/她项目是否仍然处于活动状态,否则将有必要分叉存储库并自己修复它。

于 2013-01-04T15:33:06.303 回答
1

好吧,我对旧的 scrapy-redis 进行了一些更改,以与 scrapy 0.17 兼容。它没有经过全面测试。这是代码

于 2013-01-05T04:58:23.057 回答