I can't seem to get past this and do not quite understand what is happening. I have a directory with two class files in it. Using the REPL from within that directory I can import both files and execute their logic. From their parent directory which main() is ran from however, only one class file is visible, pagetable.
The project structure is currently,
project/
src/
__init__.py # empty
pagingsimulation.py # main() imports memory
process.py
memory/
__init__.py # imports pagetable.py
pagetable.py # visible
page.py # error
pagingsimulation.py was able import memory/ and instantiate pagetable.PageTable, but once I created page.py and had pagetable.py import page.py, pagingsimulation.py now throws this error upon execution.
Traceback (most recent call last):
File "pagingsimulator.py", line 5, in <module>
import memory
File "src/memory/__init__.py", line 1, in <module>
from .pagetable import PageTable
File "src/memory/pagetable.py", line 1, in <module>
import page
ImportError: No module named 'page'
within memory/__init__.py I currently have,
from .pagetable import PageTable
...but have tried many other variations without success.
I've tried multiple approaches and have researched this for awhile and perhaps it is something I just cannot see at this point. What is preventing my custom modules from importing each other when ran from main()?