scrapinghub / scrapyrt

HTTP API for Scrapy spiders
BSD 3-Clause "New" or "Revised" License
832 stars 162 forks source link

from scrapy import signals, log as scrapy_log builtins.ImportError: cannot import name 'log' #88

Closed Hiroki111 closed 5 years ago

Hiroki111 commented 5 years ago

I installed scrapyrt today, but calling a GET request results in an error, which was reported at https://github.com/scrapy/scrapyd/issues/311

I followed the issue above, and downgraded Twisted with pip3 install Twisted==18.9.0.

After that, however, scrapyrt is producing a different error, saying...

2019-07-28 16:53:22+0200 [scrapyrt] Unhandled Error
    Traceback (most recent call last):

       ...

    File "/home/user/app/scrapy-test/my_venv/lib64/python3.6/site-packages/scrapyrt/core.py", line 9, in <module>
        from scrapy import signals, log as scrapy_log
    builtins.ImportError: cannot import name 'log'

Could I ask for help to fix it?

It's running on Python 3.6.3 Scrapy is 1.7.1

Hiroki111 commented 5 years ago

According to the doc of scrapy, there is a module called logging from scrapy.

So, I assume that the line 9 in python3.6/site-packages/scrapyrt/core.py, which is currently

from scrapy import signals, log as scrapy_log

... was actually supposed to be

from scrapy import signals, logging as scrapy_log

Any ideas?

korneel commented 5 years ago

A workaround is to downgrade Scrapy to v1.6.0.

myfoxsay commented 5 years ago

scrapy.log module has been removed in 1.7 version, after a long deprecation period.

llermaly commented 5 years ago

As @korneel says downgrading scrapy fixes the issue

pip3 uninstall scrapy pip3 install scrapy==1.6

pawelmhm commented 5 years ago

thanks for pointing this out @Hiroki111 . I'm going to fix it. To fix it we need to refactor logging. At the moment we rely on scrapy.log when creating logging observer here https://github.com/scrapinghub/scrapyrt/blob/master/scrapyrt/core.py#L89 Need to refactor logging observer to use default Python logging system instead of Scrapy custom logging functions

pawelmhm commented 5 years ago

fixed in #90