When in my app.py, I am trying to import something from models.py and when I use
from .models import *
but I’m receiving the following error on my shell
ImportError: attempted relative import with no known parent package
My directory tree looks as following:
└── PROJECT_FOLDER
├── README.md
├── __pycache__
│ ├── app.cpython-36.pyc
│ ├── app.cpython-38.pyc
│ ├── scraping.cpython-36.pyc
│ └── scraping.cpython-38.pyc
├── app.py
├── db.sqlite3
├── models.py
├── scraping.py
├── static
│ └── css
│ ├── bootstrap-theme.min.css
│ ├── bootstrap.min.css
│ ├── sign.css
│ └── theme.css
└── templates
├── base.html
└── index.html
I’ve tried putting a main.py in an outer folder and importing from PROJECT_FOLDER.models import *
but that hasn’t worked.
I also have tried putting an __init__.py
in my root directory.
Any help is appreciated. Thanks!
Tags: exception, flask, pythonpython