I am having error in importing both via relative and absolute import. Something I have done many times in the past and it used to work.
here's my folder structure:
project
├── src
│ └── notebook.ipynb
|_____ test.py
└── __init__.py
So basically within src folder (which is made a package using init.py) I have two files- notebook.ipynb and test.py
Now within notebook.ipynb, in cell I do:
from . import test
Gives the following error:
ImportError Traceback (most recent call last)
Cell In[13], line 1
----> 1 from . import test
ImportError: attempted relative import with no known parent package
Even if I try absolute import:
from src import test
I get:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[14], line 1
----> 1 from src import test
ModuleNotFoundError: No module named 'src'
Now I have used similar importing styles in past projects and it would work all fine. Within the same package I can either via relative or absolute. It doesn't NEED me to specify any PYTHONPATH in my env variable.
But this time it isn;t working.
I am using Python 3.9.15 on MAC OS installed within a conda env