TypeError: expected str, bytes or os.PathLike object, not set - error Scrapy

TypeError: expected str, bytes or os.PathLike object, not set - error Scrapy

我是Scrapy的初学者。我正在尝试下载图像并设置管道,但出现了一些错误,我对此无法理解。

books.py

class Books2Spider(Spider):
    name = 'books2'
    allowed_domains = ['books.toscrape.com']
    start_urls = ['http://books.toscrape.com']

    def parse(self, response):
        books = response.xpath('//h3/a/@href').extract()
        ...
        pass


    def parse_book(self, response):
        l = ItemLoader(item=BooksCrawlerItem(), response=response)

        title = response.css('h1::text').extract_first()
        price = response.xpath('//*[@class="price_color"]/text()').extract_first()

        image_urls = response.xpath('//img/@src').extract_first()
        image_urls = image_urls.replace('../..', 'http://books.toscrape.com/')

        l.add_value('title', title)
        l.add_value('price', price)
        l.add_value('image_urls', image_urls)

        return l.load_item()

settings.py

ITEM_PIPELINES = {
    'scrapy.pipelines.images.ImagesPipeline': 1
}

IMAGES_STORE = {
    '/home/jaki/Dev/WebScrapingScratch/images'
}

我正在抓取这个命令,scrapy crawl books2。如果一切正常,那么将下载图像。但我正面临错误。错误是,

... if os.path.isabs(uri): # to support win32 paths like: C:\some\dir File "/usr/lib/python3.6/posixpath.py", line 66, in isabs s = os.fspath(s) TypeError: expected str, bytes or os.PathLike object, not set

IMAGE_STORE 设置必须是单一路径。

替换:

IMAGES_STORE = {
    '/home/jaki/Dev/WebScrapingScratch/images'
}

与:

IMAGES_STORE = '/home/jaki/Dev/WebScrapingScratch/images'

{'asdf'} 是带有字符串 asdfset,因此出现错误消息。