Why does scrapyd throw: “'FeedExporter' object has no attribute 'slot'” exception?

雨燕双飞 提交于 2020-01-02 06:24:18

问题


I came across a situation where my scrapy code is working fine when used from command line but when I'm using the same spider after deploying (scrapy-deploy) and scheduling with scrapyd api it throws error in "scrapy.extensions.feedexport.FeedExporter" class.

  1. one is while initializing "open_spider" signal
  2. second is while initializing "item_scraped" signal and
  3. last while "close_spider" signal

1."open_spider" signal error

2016-05-14 12:09:38 [scrapy] INFO: Spider opened
2016-05-14 12:09:38 [scrapy] ERROR: Error caught on signal handler: <bound method ?.open_spider of <scrapy.extensions.feedexport.FeedExporter object at 0x7fafb1ce4a90>>
Traceback (most recent call last):
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/scrapy/extensions/feedexport.py", line 185, in open_spider
    uri = self.urifmt % self._get_uri_params(spider)
TypeError: float argument required, not dict

2."item_scraped" signal error:

2016-05-14 12:09:49 [scrapy] DEBUG: Scraped from <200 https://someurl.>
2016-05-14 12:09:49 [scrapy] ERROR: Error caught on signal handler: <bound method ?.item_scraped of <scrapy.extensions.feedexport.FeedExporter object at 0x7fafb1ce4a90>>
Traceback (most recent call last):
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/scrapy/extensions/feedexport.py", line 210, in item_scraped
    slot = self.slot
AttributeError: 'FeedExporter' object has no attribute 'slot'

3."close_spider" signal error:

2016-05-14 12:09:49 [scrapy] INFO: Closing spider (finished)
2016-05-14 12:09:49 [scrapy] ERROR: Error caught on signal handler: <bound method ?.close_spider of <scrapy.extensions.feedexport.FeedExporter object at 0x7fafb1ce4a90>>
Traceback (most recent call last):
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "/home/jonsnow/venv/scrapy1/lib/python2.7/site-packages/scrapy/extensions/feedexport.py", line 193, in close_spider
    slot = self.slot
AttributeError: 'FeedExporter' object has no attribute 'slot'

  • Scrapy: version 1.1.0
  • scrapyd: version 1.1.0

also tried with scrapyd (1.1.0 with scrapy version 0.24.6)


回答1:


It happens when feedexporter is not able to write file, it happend to me when i had my previously exported csv file open in excel. try to close the opened exported file it will work fine




回答2:


sometimes it happens even if file is closed or even result is not being saved in a file but there is some permission issue. try command with root access(sudo in linux and run as admin in windows), I have tried and the issue is resolved.



来源:https://stackoverflow.com/questions/37223700/why-does-scrapyd-throw-feedexporter-object-has-no-attribute-slot-exceptio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!