In a website I'm building with Flask I've got structure like this:
├── app
│ ├── __init__.py
│ ├── models.py
│ ├── ticket_scanner
│ │ ├── __init__.py
│ │ └── filehelper.py
│ ├── templates
│ │ └── all the templates are here..
│ └── views.py
└── run.py
I now want to import models
into ticket_scanner/__init__.py
. I tried to do this using the following import statements (with the errors behind them):
from .. import models # ImportError: cannot import name models
from . import models # ImportError: cannot import name models
import models # ImportError: No module named models
from ..models import ImageHash # ImportError: cannot import name ImageHash
As you can see it refuses to import from the models.py
file. I do have circular imports in these files, but I wouldn't know where it goes wrong. Below this message I pasted the full stacktrace of my first attempt (from .. import models
).
Does anybody know what I'm dong wrong here? All tips are welcome!
Traceback (most recent call last):
File "./run.py", line 4, in <module>
from app import app
File "/Users/kramer65/repos/fts/app/__init__.py", line 16, in <module>
import views, models
File "/Users/kramer65/repos/fts/app/views.py", line 5, in <module>
from models import Ticket
File "/Users/kramer65/repos/fts/app/models.py", line 8, in <module>
from ticket_scanner import filehelper, pdf as pdf_helper, util
File "/Users/kramer65/repos/fts/app/ticket_scanner/__init__.py", line 8, in <module>
from .. import models
ImportError: cannot import name models