Python Scrapy:导入错误:无法导入名称设置
我在尝试使用scrapy.conf.settings中的CrawlerProcess(settings)时出错,看起来scrapy文档中的内容不一致 我正在遵循一个旧的scrapy版本,我正在尝试使它与0.16的scrapy一起工作 这是我运行python脚本时出现的错误Python Scrapy:导入错误:无法导入名称设置,python,scrapy,Python,Scrapy,我在尝试使用scrapy.conf.settings中的CrawlerProcess(settings)时出错,看起来scrapy文档中的内容不一致 我正在遵循一个旧的scrapy版本,我正在尝试使它与0.16的scrapy一起工作 这是我运行python脚本时出现的错误 from scrapy import project, signals from scrapy.crawler import Settings from scrapy.crawler import CrawlerProcess
from scrapy import project, signals
from scrapy.crawler import Settings
from scrapy.crawler import CrawlerProcess
from scrapy.xlib.pydispatch import dispatcher
from multiprocessing.queues import Queue
import multiprocessing
class CrawlerWorker(multiprocessing.Process):
def __init__(self, spider, result_queue):
multiprocessing.Process.__init__(self)
self.result_queue = result_queue
self.crawler = Crawler(Settings())
if not hasattr(project, 'crawler'):
self.crawler.install()
self.crawler.configure()
self.items = []
self.spider = spider
dispatcher.connect(self._item_passed, signals.item_passed)
def _item_passed(self, item):
self.items.append(item)
def run(self):
self.crawler.crawl(self.spider)
self.crawler.start()
self.crawler.stop()
self.result_queue.put(self.items)
回溯(最近一次呼叫最后一次):
文件“server.py”,第5行,在
从刮板进口刮板
文件“/home/me/spider/spider/scraper.py”,第6行,在
从crawlerworker导入crawlerworker
文件“/home/me/spider/spider/crawlerworker.py”,第2行,在
从scrapy.crawler导入设置
导入错误:无法导入名称设置
试试:
Traceback (most recent call last):
File "server.py", line 5, in <module>
from scraper import Scraper
File "/home/me/spider/spider/scraper.py", line 6, in <module>
from crawlerworker import CrawlerWorker
File "/home/me/spider/spider/crawlerworker.py", line 2, in <module>
from scrapy.crawler import Settings
ImportError: cannot import name Settings
尝试:
请将错误添加到问题中好吗?用错误更新问题可以将错误添加到问题中好吗?用错误更新问题
from scrapy.settings import Settings