KeyError: 'Spider not found: douban_spider'

来源:2-7 spider文件的编写(2)

顺其自然s1

2018-07-15 17:46

2018-07-15 17:38:54 [scrapy.utils.log] INFO: Scrapy 1.5.1 started (bot: douban)

2018-07-15 17:38:54 [scrapy.utils.log] INFO: Versions: lxml 4.2.3.0, libxml2 2.9.5, cssselect 1.0.3, parsel 1.5.0, w3lib 1.19.0, Twisted 17.5.0, Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)], pyOpenSSL 18.0.0 (OpenSSL 1.1.0h  27 Mar 2018), cryptography 2.2.2, Platform Windows-7-6.1.7601-SP1

Traceback (most recent call last):

  File "D:\Program Files\python36\lib\site-packages\scrapy\spiderloader.py", line 69, in load

    return self._spiders[spider_name]

KeyError: 'douban_spider'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "D:/我的资料库/douban/douban/main.py", line 2, in <module>

    cmdline.execute('scrapy crawl douban_spider'.split())

  File "D:\Program Files\python36\lib\site-packages\scrapy\cmdline.py", line 150, in execute

    _run_print_help(parser, _run_command, cmd, args, opts)

  File "D:\Program Files\python36\lib\site-packages\scrapy\cmdline.py", line 90, in _run_print_help

    func(*a, **kw)

  File "D:\Program Files\python36\lib\site-packages\scrapy\cmdline.py", line 157, in _run_command

    cmd.run(args, opts)

  File "D:\Program Files\python36\lib\site-packages\scrapy\commands\crawl.py", line 57, in run

    self.crawler_process.crawl(spname, **opts.spargs)

  File "D:\Program Files\python36\lib\site-packages\scrapy\crawler.py", line 170, in crawl

    crawler = self.create_crawler(crawler_or_spidercls)

  File "D:\Program Files\python36\lib\site-packages\scrapy\crawler.py", line 198, in create_crawler

    return self._create_crawler(crawler_or_spidercls)

  File "D:\Program Files\python36\lib\site-packages\scrapy\crawler.py", line 202, in _create_crawler

    spidercls = self.spider_loader.load(spidercls)

  File "D:\Program Files\python36\lib\site-packages\scrapy\spiderloader.py", line 71, in load

    raise KeyError("Spider not found: {}".format(spider_name))

KeyError: 'Spider not found: douban_spider'

https://img.mukewang.com/5b4b17ba00019fe505400539.jpg

这是面试报错的全部信息,名字完全是一样的,还是找不到

写回答 关注

2回答

  • 大壮老师
    2018-07-16 05:48:13

    在cmd下输入scrapy看看是否输出项目名称

  • Lianger_zhou
    2018-08-20 20:25:41

    这个主要是因为你在加载项目的时候,把上一层目录作为文件夹导入进来了,重新导入,选择具体项目的那个文件夹即可

    二的二次方

    正解呀~解决问题了

    2020-04-02 15:32:03

    共 1 条回复 >

Python最火爬虫框架Scrapy入门与实践

做为爬虫工程师Python Scrapy主流爬虫框架你必须要会!

67418 学习 · 223 问题

查看课程

相似问题