在 Python3.6 的 virtualenv 上没有名为“_sqlite3”的模块

xii*_*vil 6 python sqlite virtualenv scrapy

我正在尝试在https://doc.scrapy.org/en/1.3/intro/tutorial.html上运行示例,当我使用 scrapy crawl 引号运行蜘蛛时,我收到错误:

ModuleNotFoundError: 没有名为“_sqlite3”的模块

我正在使用 python 3.6 在 vi​​rtualenv 中运行,如何修复错误以运行我的脚本?谢谢

更新

脚本是:

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)
Run Code Online (Sandbox Code Playgroud)

小智 0

尝试:

sudo apt-get install libsqlite3-dev
Run Code Online (Sandbox Code Playgroud)