gpt4 book ai didi

python - 类 InstagramSpider(scrapy.Spider) : AttributeError: 'module' object has no attribute 'Spider'

转载 作者:太空宇宙 更新时间:2023-11-03 14:55:59 28 4
gpt4 key购买 nike

我该如何解决这个错误?

mona@pascal:~/computer_vision/instagram/instagram$ scrapy crawl instagramspider
2017-03-01 17:24:03-0600 [scrapy] INFO: Scrapy 0.14.4 started (bot: instagram)
2017-03-01 17:24:04-0600 [scrapy] DEBUG: Enabled extensions: LogStats, TelnetConsole, CloseSpider, WebService, CoreStats, MemoryUsage, SpiderState
Traceback (most recent call last):
File "/usr/bin/scrapy", line 4, in <module>
execute()
File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 132, 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 139, in _run_command
cmd.run(args, opts)
File "/usr/lib/python2.7/dist-packages/scrapy/commands/crawl.py", line 43, in run
spider = self.crawler.spiders.create(spname, **opts.spargs)
File "/usr/lib/python2.7/dist-packages/scrapy/command.py", line 34, in crawler
self._crawler.configure()
File "/usr/lib/python2.7/dist-packages/scrapy/crawler.py", line 36, in configure
self.spiders = spman_cls.from_crawler(self)
File "/usr/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 37, in from_crawler
return cls.from_settings(crawler.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/mona/computer_vision/instagram/instagram/instagram/spiders/spider.py", line 7, in <module>
class InstagramSpider(scrapy.Spider):
AttributeError: 'module' object has no attribute 'Spider'

更多信息可以在这里找到: From scraper_user.items import UserItem ImportError: No module named scraper_user.items

Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrapy
>>> print scrapy.__file__
/usr/lib/python2.7/dist-packages/scrapy/__init__.pyc
>>> print(dir(scrapy))
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', 'boto', 'optional_features', 'os', 'sys', 'twisted_250_monkeypatches', 'urlparse_monkeypatches', 'version_info', 'warnings', 'xlib']
>>> print(scrapy.spider)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'spider'

最佳答案

根据输出,您使用的是非常非常旧的 Scrapy 0.14.4,它没有将 Spider 暴露到 scrapy 命名空间。

任一更新:

pip install scrapy --upgrade

或者,将您的导入更改为(不确定这是否会按原样工作):

from scrapy.spider import BaseSpider as Spider

关于python - 类 InstagramSpider(scrapy.Spider) : AttributeError: 'module' object has no attribute 'Spider' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42544109/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com