Unable to import items in scrapy

后端 未结 4 1165
广开言路
广开言路 2021-01-06 05:27

I have a very basic spider, following the instructions in the getting started guide, but for some reason, trying to import my items into my spider returns an error. Spider a

4条回答
  •  走了就别回头了
    2021-01-06 06:10

    if the structure like this:

    package/
        __init__.py
        subpackage1/
            __init__.py
            moduleX.py
            moduleY.py
        subpackage2/
            __init__.py
            moduleZ.py
        moduleA.py
    

    and if you are in moduleX.py, the way to import other modules can be:

    from .moduleY.py import *
    
    from ..moduleA.py import *
    
    from ..subpackage2.moduleZ.py import *
    

    refer:PEP Imports: Multi-Line and Absolute/Relative

提交回复
热议问题