I am sorry I have to ask this question. It feels stupid, because I am sure the answer is somewhere and I can just not find it. All posts I read give me the feeling I did things right but obviously its not ...
I get an ImportError: No module named test_framework
and I do really not understand why.
My folder structure is:
src/
|
-- test/
| |
| -- test_framework/
| | |
| | -- __init__.py
| | -- device.py
| |
| -- __init__.py
|
-- myPackage/
|
-- __init__.py
-- dbg_session.py
-- main.py
In dbg_session.py I have the following line which produces the error:
from test.test_framework import device
I also tried to insert the following line before the import:
sys.path.append(PROJECT_ROOT) # pointing to src/
from test.test_framework import device
Also did not help:
import test.test_framework.device
the error is then:
ImportError: No module named test_framework.device
which looks to me as test
was found but not the folder test_framework
.
I am calling my program from src
with something like python.exe myPackage/main.py
If I change the import to
sys.path.append(os.path.join(PROJECT_ROOT, 'test'))
from test_framework import device
it works fine but feels not right and pylint is complaining that the import cannot be resolved. My question looks like this one: ImportError: No module named - Python but I think I got the paths right. PROJET_ROOT is a relative path, I also tried to insert the absolute path on my disk there, but that did not help. I am pretty sure that PROJET_ROOT points correctly to src, we use this at many places.