I am getting the famous – ModuleNotFoundError
when I try to import a module from another folder. Here is the folder structure –
packages
- packageA
- src
- packagename
- app.py <-- imports the readers.reader_module
- __init__.py
- readers
- __init__.py
- reader_module.py <-- contains a read()
The source under packagename
will be packaged and hence I have added __init__.py
under it. Similarly, under readers
folder __init__.py
is added.
When I import reader_module
in app.py
I get – ModuleNotFoundError: No module named 'packagename'
.
I tried below import statements inside app.py
but no luck –
from packagename.readers.reader_module import read
from .readers.reader_module import read
from readers.reader_module import read