Let's say that I have a project with the directory structure as follows:
project
\__ cfgs
\__ __init__.py
\__ config.py
\__ src
\__ __init__.py
\__ model1
\__ __init__.py
\__ test.py
\__ model2
\__ test2.py
I want to run the Python script test.py
. However, I need to import a module named Config
from the file project/cfgs/config.py
. How would I correctly import it?
Within test.py
I've tried the following:
# Returns a `No module named 'cfgs'` error.
from cfgs import Config
# Returns `Attempted relative import with no known parent package` error.
from ..cfgs import Config