I know that this question was already widely discussed, but I didn't find an answer. I'm getting error ImportError: No module named items. I've created a new project with $ scrapy startproject pluto and I have no equal names (in names of project, classes etc), to avoid problem with naming.
pluto_spider.py :
import scrapy
from items import PlutoItem
class PlutoSpider(scrapy.Spider):
name = "plutoProj"
allowed_domains = ['successories.com']
start_urls = [
'http://www.successories.com/iquote/category/39/inspirational-quotes/4',
'http://www.successories.com/iquote/category/39/inspirational-quotes/6',
]
def parse(self,response):
items = []
for quote in response.css('div.quotebox'):
item = PlutoItem()
item['author'] = quote.css('span.author a::text').extract_first()
item['quote'] = quote.css('div.quote a::text').extract_first()
items.append(item)
return items
item.py :
import scrapy
class PlutoItem(scrapy.Item):
author = scrapy.Field()
quote = scrapy.Field()
This my folder's hierarchy:
/pluto
/pluto/scrapy.cfg
/pluto/pluto/__init__.pyc
/pluto/pluto/__init__.py
/pluto/pluto/items.py
/pluto/pluto/pipelines.py
/pluto/pluto/settings.py
/pluto/pluto/settings.pyc
/pluto/pluto/spiders/__init__.py
/pluto/pluto/spiders/__init__.pyc
/pluto/pluto/spiders/pluto_spider.py
/pluto/pluto/spiders/pluto_spider.pyc
It looks like your
items.py
andpluto_spider.py
are at different levels. You should make your import eitherfrom pluto import items
or a relative importimport ..items
per PEP 328 to import the module.If you want the class
from pluto.items import PlutoItem
First of all, make sure to execute the Scrapy command from inside the top level directory of your project.
Or you may also try changing your import to: