On ubuntu, I am working with the following structure:
.
├── src
│ ├── __init__.py
│ └── main.py
└── test
├── __init__.py
└── test.py
The main.py
contains the following function:
def fun(x,y):
return x+y
And the test.py has
from src.main import fun
print(fun(2,3))
I am working in the directory daddy
. So pwd
prints daddy
.
When I try calling test.py
,
$ python3 test/test.py
Traceback (most recent call last):
File "test/test.py", line 1, in <module>
from src.main import fun
ModuleNotFoundError: No module named 'src'
What options do I have, to get this right ?
I have gone through other answers related to this and they don't work for me... chiefly because they don't deal with working directory unlike my case.