SplashRequest gives - TypeError: attrs() got an unexpected keyword argument 'eq'
Asked Answered
I

2

11

I am using a cloud Splash instance from ScrapingHub. I am trying to do a simple request using the Scrapy-Splash library and I keep getting the error:

@attr.s(hash=False, repr=False, eq=False)
TypeError: attrs() got an unexpected keyword argument 'eq'

Any ideas/clues about why the error is showing up would be much appreciated.

The code I'm using looks like this (using Python 3.6 and Scrapy v 2.1.0):

import scrapy
from scrapy_splash import SplashRequest


class MySpider(scrapy.Spider):
    start_urls = ['https://www.sportsgirl.com.au', 'http://maryons.com.au']

    def start_requests(self):
        for url in self.start_urls:
            yield SplashRequest(url, self.parse, args={'wait': 0.5})

    def parse(self, response):    
        print(response)


MySpider().start_requests()

and settings.py has the following values:

DOWNLOADER_MIDDLEWARES = {
    'scrapy_splash.SplashCookiesMiddleware': 723,
    'scrapy_splash.SplashMiddleware': 725,
    'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
}

SPIDER_MIDDLEWARES = {
    'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
}

SPLASH_URL = 'https://my-splash-url.scrapinghub.com'
Incondite answered 20/5, 2020 at 3:31 Comment(2)
Probably a bug. File a ticket with the repository.Peyter
Thanks, I'll send them a message to confirm. If it is a bug I'll open a ticket.Incondite
P
27

The error is coming from the Twisted library, which is a dependency of Scrapy.

It looks like it's fixed in the latest version. If you run

pip install --upgrade twisted

you should be fine!

Pacify answered 14/6, 2020 at 20:26 Comment(2)
thank you! Scrappy needs to fix their dependencies version asapHarriettharrietta
Remember to upgrade attrs in your virtual environment (venv)Infare
M
4

I also had to upgrade attrs in order to make the error message disappear.

pip3 install attrs==19.2.0 -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

I found this on: https://www.programmersought.com/article/61587312947

Malanie answered 7/5, 2021 at 9:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.