Python uses PYTHONPATH environment variable to define a list of folders which should be looked at when importing modules. Most likely your folder is not PYTHONPATH
Answer from Kozyarchuk on Stack OverflowImport issues in Python - Stack Overflow
Python importing issue I'm having - Stack Overflow
python import problem - Stack Overflow
How does one fix an import error like the following?
is main/src in sys.path? Python resolves module names by searching the directories in sys.path. For example "import ../module.py" is not valid. To fix your problem do something like this: In your "main/tests/test.py" file add:
import sys, os
sys.path.insert(0, os.path.abspath("../src") )
# Then try
from domain.entries import MyClass
You will also need to make sure that main/src/domain contains an init.py file. Also you don't need init.py in main/tests unless your going to add it's parent directory to your path and import tests.something.
Hope this helps.
You need __ini__.py in every directory within the package
main/__init__.py
main/src/__init__.py
main/src/domain/__init__.py
main/src/domain/entities.py
main/tests/__init__.py
You shoud not add the project directory to your pythonpath but it's parent, e.g. imagine the setup
/home/user/develop/project/src/model
You'd add /home/user/develop to PYTHONPATH
If that still doesn't work, make sure you don't have a 'project.py' insite project/src/model.
Make sure you have the parent directory of project/ on your pythonpath, rather than the project directory. If you add the project path itself, imports like import project.src will look for project/project/src.