3

Hi am trying to run a scraper on ubuntu/windows machine . I have installed scrapy version- Scrapy 1.8.0 on using python2. I am able create a project, but when I run a scraper this error in shown.

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/scrapy", line 8, in <module>
    sys.exit(execute())
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 146, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 100, in _run_print_help
    func(*a, **kw)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 154, in _run_command
    cmd.run(args, opts)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/commands/shell.py", line 68, in run
    crawler.engine = crawler._create_engine()
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/crawler.py", line 111, in _create_engine
    return ExecutionEngine(self, lambda _: self.stop())
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/core/engine.py", line 67, in __init__
    self.scheduler_cls = load_object(self.settings['SCHEDULER'])
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/utils/misc.py", line 46, in load_object
    mod = import_module(module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/core/scheduler.py", line 7, in <module>
    from queuelib import PriorityQueue
  File "/home/ubuntu/.local/lib/python2.7/site-packages/queuelib/__init__.py", line 1, in <module>
    from queuelib.queue import FifoDiskQueue, LifoDiskQueue
  File "/home/ubuntu/.local/lib/python2.7/site-packages/queuelib/queue.py", line 7, in <module>
    from contextlib import suppress
ImportError: cannot import name suppress

can anyone help to solve this issue?

imgroot
  • 31
  • 4

2 Answers2

2

The contextlib.suppress function supports from Python 3.4 but you are using Python 2.7. To solve this problem, upgrade your python version.

Shivam
  • 610
  • 1
  • 5
  • 6
2

If this is useful for someone else, the solution for me (also using python 2.7) was:

pip uninstall attrs
pip uninstall queuelib
pip install queuelib==1.5.0
pip install attrs
brenda
  • 656
  • 8
  • 24