Wednesday, October 17, 2018

python - ImportError: No module named

I have a project which has a folder structure like so:



project:
folder1:
__init__.py
file11.py
folder2:
__init__.py
file21.py
folder3:

__init__.py
file31.py
__init__.py
file1.py
file2.py
..


From the root of the project, I am able to import the files on same path




Example,



In file1.py, from file2 import 123 and from folder3.file31 import 456 works



In file21.py, import file1 works



My issue is triggered when I do this:



Example,




In file21.py, from folder3.file31 import xyz



This is throwing an error like ImportError: No module named folder3



All my __init__.py files are empty and make python believe they are packages. I do not understand why this is happening. I would like to know a solution for this and also some little insights on how it works.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...