Failed to access instance of a pyscript from sub directory

Viewed 9

In a flask app, I defined a pymongo instance in a factory.py that's in the root directory, while accessing the same from a subdirectory raises a ValueError.Please find the directory structure.

root
    -- controllers
            -- auth_controller
                    -- a.py
            -- node_controller
                    -- b.py
    -- config.py
    -- factory.py
    -- run.py

In a.py I tried to access a PyMongo instance from factory.py, and it ended up following the error

from ...factory import mongo
ValueError: attempted relative import beyond top-level package
0 Answers
Related