I'm working on a python project in JupyterLab and I'm confused about the package and module import. I get a ModuleNotFoundError (see below) and I don't understand why.
This is my abstracted folder structure:
top/
|
|– sub
| |– __init__.py
| |– pre.py
| |– post.py
| |– sub_main.ipynb
|
|– top_main.ipynb
The __init__.py
is empty.
These are my imports:
post.py
from pre import xyz
sub_main.ipynb
import pre, post
top_main.ipynb
from sub import pre
from sub import post
ModuleNotFoundError: No module named pre
So, from sub import pre
is working, but from sub import post
is not.
Does anyone know what I'm doing wrong?
Thanks!
carlo