Scrapy KeyError找不到spid

2024-09-30 12:26:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个废弃的项目,它不会从命令行使用scrapy crawl <spider-name>执行。在

我刚刚在Ubuntu16.04上迁移到了一个新的开发环境,所以我想再次检查一下这个问题是否与我的设置无关。为此,我使用python 2.7.12创建了一个干净的虚拟环境virtualenvwrapper,并遵循了Scrapy docs中的tutorial instructions。(v1.1以模仿我的另一个项目)。在

尽管有了新的环境,我还是看到了一些奇怪的行为,但它不会:

  • 列出蜘蛛scrapy list
  • 列出设置scrapy settings
  • 开始爬网scrapy crawl quotes

scrapy crawl quotes引发以下错误:

2017-01-06 14:20:50 [scrapy] INFO: Scrapy 1.1.1 started (bot: scrapybot)
2017-01-06 14:20:50 [scrapy] INFO: Overridden settings: {}
Traceback (most recent call last):
  File "/home/alan/QueryClick/.virtualenvs/test/bin/scrapy", line 11, in <module>
    sys.exit(execute())
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 142, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 88, in _run_print_help
    func(*a, **kw)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 149, in _run_command
    cmd.run(args, opts)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/commands/crawl.py", line 57, in run
    self.crawler_process.crawl(spname, **opts.spargs)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/crawler.py", line 162, in crawl
    crawler = self.create_crawler(crawler_or_spidercls)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/crawler.py", line 190, in create_crawler
    return self._create_crawler(crawler_or_spidercls)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/crawler.py", line 194, in _create_crawler
    spidercls = self.spider_loader.load(spidercls)
  File "/home/alan/QueryClick/.virtualenvs/test/local/lib/python2.7/site-packages/scrapy/spiderloader.py", line 43, in load
    raise KeyError("Spider not found: {}".format(spider_name))
KeyError: 'Spider not found: quotes'

我的目录结构是:

^{pr2}$

我还仔细检查了我的所有系统需求,如Scrapy文档中所述。这个问题在我的团队中被复制,在Ubuntu14.04上遵循与virtualenv相同的步骤和我的相同设置。在

如果有人能对此有所启示,我将永远感激。在


编辑:添加settings.py

settings.py中唯一活跃的是:

BOT_NAME = 'tutorial'
SPIDER_MODULES = ['tutorial.spiders']
NEWSPIDER_MODULE = 'tutorial.spiders'
ROBOTSTXT_OBEY = True

编辑:共享scrapy.cfg

# Automatically created by: scrapy startproject
#
# For more information about the [deploy] section see:
# https://scrapyd.readthedocs.org/en/latest/deploy.html

[settings]
default = tutorial.settings

[deploy]
#url = http://localhost:6800/
project = tutorial

Tags: inpytesthomelibpackageslocalline
2条回答

这与为调用spider的django项目设置的一些环境变量有冲突-它们的名称空间是SCRAPY_,并且一定是冲突的。在

编辑:供参考:GitHub issue on undocumented environment variable(s)

确保你的spider是.py,例如,如果是从jupyter创建的,它可能是.ipynb,它将不会被提取。在

相关问题 更多 >

    热门问题