简体   繁体   中英

Python- no module named error. wherever i place the __init__.py file the ingestor file just cant seem to get at it


project structure


__init__.py
backend

      __init__.py

      /log_parser.py

      /ingestor

      /data_aggregation

configuration

scripts

    __init__.py(holding create_app and db)

UI

utils

    /__init__.py

    /models





inside of the log parser is this import

from ingestor import Ingestor

however whenever the ingestor file gets to here

from scripts import create_app, db it fails with the error message

ModuleNotFoundError: No module named 'scripts' (venv)

ive tried changing the directory the init .py file is in with no luck. I've also tried importing everything within a directory which also failed. so i'm out of ideas?

If with "/" you mean that the __init__.py and ingestor ar on the same folder. Make sure that inside this one (ingestor folder) there is outher __init__.py file and try again.

If yes but always facing the same problem, try with a relative import like this: from.ingestor import Ingestor . Don't miss the "dot" before "ingestor"

If it doesn't work try this last one:

import sys
sys.path.append(".")
from ingestor import Ingestor

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