I recently built a package with python and init.py files however for some reason they are not working. I have managed to replicate the issue in a smaller scale. Suppose I have the following directory structure: . dir_a file_a.py file_b.py __init__.py test.py with file_a having a finction whichh returns a variable from file_b. test.py imports the entire package and attempts to call the function. However i always end up with the error: ``` Traceback (most recent call last): File "/home/jeebak/Dev/Python/test/test.py", line 1, in import dir_a File "/home/jeebak/Dev/Python/test/dir_a/__init__.py", line 1, in from dir_a.file_a import * File "/home/jeebak/Dev/Python/test/dir_a/file_a.py", line 1, in import file_b ModuleNotFoundError: No module named 'file_b' ``` the contents of __init__.py: ```py from dir_a.file_a import * from dir_a.file_b import * ``` the contents of test.py: ```py import dir_a print(dir_a.fn()) ``` the contents of of file_a: ```py import file_b def fn(): return b.txt ``` The contents of file_b: ```py txt = "Hello World" ```
absolute imports like `import file_b` are always interpreted in the same way you would write them from your starting script, that being test.py in your case in other words, your test.py can import file_b by doing `from dir_a import file_b`, which means file_a.py must write its absolute import in the same way, `from dir_a import file_b`