0

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

1 Answer 1

1

In this case you are required to add __init__.py for each of the directories. Otherwise it doesn't understand these folders as packages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.