简体   繁体   中英

there is problem in importing my class in scrapy spider

I am facing problem since one week .I was not able to import my class in the scrapy spider(in shareprice.py).I have tried many ways but not found anywhere please give me the solution . shareprice.py and my class in the same directory in spiders

import scrapy
import json
import sys
from .myclass import * 

The error I get is:

error -attempted relative import with no known parent package

To make a directory a real python package place an empty __init__.py file in it. Also import * something is bad practice most of the time. You should only import functions and classes you really need (explicit is better than implicit).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM