Start a new topic
Answered

ImportError: cannot import name 'log'

Hi there,


Having a bit of trouble with this one and can't seem to pinpoint the issue. This is on scraping hub, no issues on local at all.


I've also specified that I am using python3.6 in my pipfile so not entirely sure why it is referencing python 3.5.


Any help would be much appreciated!


2019-08-04T20:46:03.288292 Traceback (most recent call last):

 Less

  File "/usr/local/lib/python3.5/site-packages/sh_scrapy/crawl.py", line 165, in _launch
    from sh_scrapy.log import initialize_logging
  File "/usr/local/lib/python3.5/site-packages/sh_scrapy/log.py", line 7, in <module>
    from scrapy import log, __version__

ImportError: cannot import name 'log'

Best Answer

Scrapy stack 1.7 was released 3 days ago, so use this stack instead of adding scrapy 1.7.3 to your requirements.txt on an older stack.


1 person has this question

Hello,


What is the version of Scrapy used in local?

In the scrapy cloud, Scrapy 1.7.3 has been used as per the requirements.txt. scrapy.log has been deprecated in the recent versions as given in https://docs.scrapy.org/en/latest/topics/logging.html#topics-logging and it now uses Python's builtin Logging system. 


Hence you would need to use as below:

import logging
import scrapy



I am getting the exact same issue and not sure why. I am using python 3.6, I have the requirements.txt file in the same directory as scrapy.cfg and its showing python 2.7 not sure why either. I just updated this to scrapy 1.7.3 from 1.6. Working fine on local but not on scraping hub. I did try adding import logging to the spider but did not help. 


  File "/usr/local/lib/python2.7/site-packages/sh_scrapy/crawl.py", line 165, in _launch
    from sh_scrapy.log import initialize_logging
  File "/usr/local/lib/python2.7/site-packages/sh_scrapy/log.py", line 7, in <module>
    from scrapy import log, __version__
Answer

Scrapy stack 1.7 was released 3 days ago, so use this stack instead of adding scrapy 1.7.3 to your requirements.txt on an older stack.

Changed the requirements.txt file to use Scrapy1.7 still facing the same issue.


Login to post a comment