'Own module import not working and no solution in other questions found

Common question, but I have not found a solution reading >10 question threads.

I have the following directory:

ParentFolder
├───notebooks
│   │   .gitkeep
│   │   1raw_eda.ipynb
│   │   2raw_feature_engineering.ipynb
│   │   3advanced_eda.ipynb
│   │   4advanced_feature_engineering.ipynb
│   │   5modelling.ipynb
│   │   __init__.py
|
├───src
│   │   __init__.py
│   ├───features
│   │       .gitkeep
│   │       build_features.py
│   │       __init__.py
|
|__init__.py

I am in 1raw_eda.ipynb, my os.getcwd() is notebooks. If i now try import ParentFolder.src.features.build_features, I am getting a No module named 'ParentFolder' error and I don't know why as I have __init__.py everywhere.

Additional Information: ParentFolder is capitalized like this and I just changed its name from Parent-Folder to ParentFolder, in case this is relevant. I have no info whether the import worked before as I didn't try it before (actually I renamed it to allow for the import).

Thanks already!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source