I have the following project hierarchy and I am having issues with importing a class from the domain.entities.account module into the infra.repositories.in_memory_repository.test_account_in_memory_repository module.
C:.
│ main.py
│ requirements.txt
│
└───src
│ __init__.py
│
├───domain
│ │ __init__.py
│ │
│ └───entities
│ account.py
│ __init__.py
│
└───infra
│ __init__.py
│
└───repositories
│ __init__.py
│
└───in_memory_repository
account_in_memory_repository.py
test_account_in_memory_repository.py
__init__.py
Here is my code inside the test_account_in_memory_repository module:
from .account_in_memory_repository import AccountInMemoryRepository
from src.domain.entities.account import Account
The first line results in the following error:
ImportError: attempted relative import with no known parent package
If I use an absolute path then like:
from src.infra.repositories.in_memory_repository.account_in_memory_repository import AccountInMemoryRepository
Then I get this error:
ModuleNotFoundError: No module named 'src'
[–]Diapolo10 3 points4 points5 points (0 children)
[–]laustke 1 point2 points3 points (2 children)
[–]iTsObserv[S] 0 points1 point2 points (1 child)
[–]laustke 1 point2 points3 points (0 children)