My project directory looks like this:
project/
├─ new/
│ ├─ test.py
├─ docs.py
├─ main.py
Within my main.py, I import a function from docs.py
like this:
from docs import get_my_conn
and it works fine.
How can I import the same thing within new/test.py
as well? I tried:
from ..docs import get_my_conn
but I get this error:
ImportError: attempted relative import with no known parent package
The issue is in how you are running your code - you should add the init files as in
then run your code as
from the
project
folder.