AttributeError: 'module' object has no attribute 'Spider'


************************执行代码********************
sun@sun-Lenovo:~$ cd tutorial

sun@sun-Lenovo:~/tutorial$ scrapy crawl dmoz

************************执行代码完的******************************************************
2014-11-25 12:33:37+0800 [scrapy] INFO: Scrapy 0.12.0.2546 started (bot: tutorial)
2014-11-25 12:33:37+0800 [scrapy] DEBUG: Enabled extensions: TelnetConsole, SpiderContext, WebService, CoreStats, MemoryUsage, CloseSpider
Traceback (most recent call last):
File "/usr/bin/scrapy", line 4, in
execute()
File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 131, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 97, in _run_print_help
func(*a, **kw)
File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 138, in _run_command
cmd.run(args, opts)
File "/usr/lib/python2.7/dist-packages/scrapy/commands/crawl.py", line 42, in run
q = self.crawler.queue
File "/usr/lib/python2.7/dist-packages/scrapy/command.py", line 33, in crawler
self._crawler.configure()
File "/usr/lib/python2.7/dist-packages/scrapy/crawler.py", line 36, in configure
self.spiders = spman_cls.from_settings(self.settings)
File "/usr/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 33, in from_settings
return cls(settings.getlist('SPIDER_MODULES'))
File "/usr/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 23, in __init__
for module in walk_modules(name):
File "/usr/lib/python2.7/dist-packages/scrapy/utils/misc.py", line 65, in walk_modules
submod = __import__(fullpath, {}, {}, [''])
File "/home/sun/tutorial/tutorial/spiders/dmoz_spider.py", line 3, in
class DmozSpider(scrapy.Spider):
AttributeError: 'module' object has no attribute 'Spider'

****************结束*********************************************************************************
请问这个错误是怎么回事,scrapy(0.12的)的版本低吗
AttributeError: 'module' object has no attribute 'Spider'
有时还会出现下面这个错误
AttributeError: 'module' object has no attribute 'Any'********

python Ubuntu scrapy

十万红白无节操 10 years, 1 month ago

版本太低了,可以看下0.12的tutorial( http://doc.scrapy.org/en/0.12/intro/tutorial.html )。

营业街店主 answered 10 years, 1 month ago

Your Answer