I have a simple situation on a linux system:
ls test_repo
example __init__.py text
In text
directory, I just have 2 files:
__init__.py ex.py
In example
directory, I have just 2 files again:
__init__.py test.py
In ex.py
I have the code:
def test():
print(10)
Now, in text directory I want to import it:
from text.ex import test
print(test())
But when I run the file in the example directory as well as out of it: python test.py
I get the error:
Traceback (most recent call last):
File "test.py", line 1, in <module>
from text.ex import test
ModuleNotFoundError: No module named 'text'
How can I import the function?
Should I put something in __init__.py
?