I have a hierarchy of packages like this:
dir/
subdir1/
__init__.py
module3.py
module4.py
__init__.py
module1.py
module2.py
There is a msg variable in module2 and module4 respectively.
I import module2 in module1, and it works:
import module2
print(module2.msg)
But when I import module4 in module3, vscode gives me the error: [pylint] E0401:Unable to import 'module4'. However, when I run it by python .\subdir1\module3.py, python interpreter doesn't complain this and run smoothly:
import module4
print(module4.msg)
What's the problem?


import subdir1.module4, also i smell a duplicate of this somewhere.import module4, but actuallly there is no error when I run it. And when I change that line toimport subdir1.module4, vscode doesn't complain error though, but when I run it, python give me errorModuleNotFoundError: No module named 'subdir1'. Please help me, is there something I messed up?