KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a directory structure: network/__init__.py network/model.py network/transformer/__init__.py network/transformer/t_model.py both __init__.py files have appropriate __all__ = [ "model", # or "t_model" in the case of transformer "view", ] In t_model.py, I have from .. import model but it says: ImportError: cannot import name model If I try from ..model import Node it says: ImportError: cannot import name Node These are very confusing errors. Edit: Even an absolute import fails: import network as N print(dir(N), N.__all__) import network.model as M ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'transformer'] ['model', 'view'] Traceback (most recent call last):.......... AttributeError: 'module' object has no attribute 'model' Edit: It was a circular import .
Tags (comma-separated)
Save Edits
Cancel