[Fixed]-Import Error when trying to import scrapy spider into django

1๐Ÿ‘

โœ…

As I can see there are 2 errors:

  1. There is extra ticket_city_scraper in your path.

    Should be:

    from trydjango18.ticket_city_scraper.ticket_city_scraper.spiders.tc_spiders import spiderCrawl
    
  2. There is no tc_spiders.py.

    Either add tc_spiders.py or import from tc_spider.py.

Considering that you asked about

the spider.py file

I assume that you meant tc_spider.py, thus a complete solution is:

from trydjango18.ticket_city_scraper.ticket_city_scraper.spiders.tc_spider import spiderCrawl

Also make sure that:

  1. Each package contains __init__.py.
  2. tc_spiders.py/tc_spider.py contains module-level function spiderCrawl.
๐Ÿ‘คErnest

Leave a comment