Issue
I have a project structure as given below:
src/
-----test/
---------__init__.py
---------run_test.py
-----moduleA/
---------__init__.py
---------targets.py
---------features.py
---------test_analysis.ipynb
---__init__.py
---logger.py
In my targets.py I have the following imports:
from src.moduleA import features
from src import logger
In my features.py I have the following imports:
from src import logger
I have set my current working directory to : src/
so for now it works fine, however I want to use targets.py and features.py file in my test_analysis.ipynb
I am importing it like this in notebook:
from src.moduleA import features
However it gives me the following error :
ImportError: No module named src.moduleA
Note: I am using python 2
Solution
In this case you are required to add __init__.py
for each of the directories. Otherwise it doesn't understand these folders as packages.
Answered By - Pasan Chamikara
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.