从Django.db公司import utils ImportError:无法导入name utils

2024-06-26 14:23:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我为scrapy编写了一个自定义命令:

from pyes import *
from eScraperInterface import settings
from django.core.management import setup_environ
setup_environ(settings) 
from eScraperInterfaceApp.models import scrapedData
from eScraperInterfaceApp.eScraper_utils import eScraperUtils 
#------------------------------------------------------------------------------ 

class indexData():

    def __init__(self):
        self.utilsOBJ = eScraperUtils()
        conn = ES('127.0.0.1:9200')
        conn.create_index("scraped_data")

    def run(self):
        for i in scrapedData.objects.filter():
            data = {'productTitle':i.productTitle,'productSite':i.productSite,
                    'productURL':i.productURL,'productDesc':i.productDesc,
                    'productCategory':i.productCategory,'productSubCategory':i.productSubCategory,
                    'productMRP':i.productMRP,'productPrice':i.productPrice,'hasVariants':i.hasVariants,
                    'availability':i.availability,'currency':i.currency,'image_paths':i.image_paths}

            a = self.utilsOBJ.create_Index(data)
            print a

当我尝试使用scrapy shell命令时,出现了以下错误:

^{pr2}$

Tags: fromimport命令selfdatasettingsdefsetup