You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering two main issues related to import management:
Circular Import: I want to import from a sibling package. If I do from pneuma.utils.response import Response, ResponseStatus from registration.py and try to run the script directly, ModuleNotFoundError: No module named 'pneuma' occurs. Additionally, if pneuma.py is run, ImportError: cannot import name 'Registration' from partially initialized module 'registration.registration' (most likely due to a circular import) (xxx\Pneuma\pneuma\registration\registration.py) occurs.
Relative import error: If I do from ..utils.response import Response, ResponseStatus instead, ImportError: attempted relative import with no known parent package occurs, both when running the scripts directly and running pneuma.py
Below is the current simplified project structure:
Right now, the fix is doing sys.path.append(str(Path(__file__).resolve().parent.parent)) and importing with from utils.response import Response, ResponseStatus to import from sibling packages.
Request for help:
Suggestions for restructuring the code to avoid circular imports.
Best practices for import management in this project.
The text was updated successfully, but these errors were encountered:
I am encountering two main issues related to import management:
from pneuma.utils.response import Response, ResponseStatus
from registration.py and try to run the script directly, ModuleNotFoundError: No module named 'pneuma' occurs. Additionally, if pneuma.py is run, ImportError: cannot import name 'Registration' from partially initialized module 'registration.registration' (most likely due to a circular import) (xxx\Pneuma\pneuma\registration\registration.py) occurs.from ..utils.response import Response, ResponseStatus
instead, ImportError: attempted relative import with no known parent package occurs, both when running the scripts directly and running pneuma.pyBelow is the current simplified project structure:
Right now, the fix is doing
sys.path.append(str(Path(__file__).resolve().parent.parent))
and importing withfrom utils.response import Response, ResponseStatus
to import from sibling packages.Request for help:
The text was updated successfully, but these errors were encountered: