6
votes

I'm trying to run the example on https://doc.scrapy.org/en/1.3/intro/tutorial.html, when i run the spider using scrapy crawl quotes i get the error:

ModuleNotFoundError: No module named '_sqlite3'

I'm running inside a virtualenv with python 3.6, how can i fix the error to run my script? Thanks

UPDATE

The script is:

import scrapy


class QuotesSpider(scrapy.Spider):
name = "quotes"

def start_requests(self):
    urls = [
        'http://quotes.toscrape.com/page/1/',
        'http://quotes.toscrape.com/page/2/',
    ]
    for url in urls:
        yield scrapy.Request(url=url, callback=self.parse)

def parse(self, response):
    page = response.url.split("/")[-2]
    filename = 'quotes-%s.html' % page
    with open(filename, 'wb') as f:
        f.write(response.body)
    self.log('Saved file %s' % filename)
1
It's impossible to say without seeing your script. Can you post it? - ilmarinen
@ilmarinen yes of course, is the one in the link i put in the question, i update the answer to put it right there. - CarlosJavier
Very rough guess, but do you happen to have a file named sqlite or sqlite3 in your working directory? Python's importing mechanism gives files in the working directory precedence over other locations - ilmarinen
I'm seeing similar behaviour for Scrapy 1.5 & Python 3.6 & pipenv (deployed on AWS) - declension
Please, post the whole traceback of the error so that we can see where it comes from. - Gallaecio

1 Answers

0
votes

Try:

sudo apt-get install libsqlite3-dev