My Flask project is structured as follows:
my_project
│
├── app
│ ├── __init__.py
│ ├── api
│ ├── static
│ └── templates
├── config.py
└── run.py
I was facing same issue for below line in my app,
import app.main.constant.constants as Constants
but then I restructure above command to below, and It worked for me.
from app.main.constant import constants as Constants
I fixed this issue by renaming the app directory to something else (e.g. webapp). Using from webapp import app does the trick. This seems to be because package directory names take precedence over module names when importing. Perhaps using __path__ would allow one to get around this.
I solved this issue by doing this in my runserver.py:
from WebApp import app
app.app.run(debug=True)
Where the name of the package is Webapp. Noticed how I used app twice. Also, my Flask app is called app.
├── WebApp
│ ├── app.py
│ ├── authentication.py
│ ├── __init__.py
│ ├── models.py
├── runserver.py