Flask AttributeError: module 'app' has no attribute 'run'

前端 未结 3 1397
说谎
说谎 2021-01-18 18:38

My Flask project is structured as follows:

my_project
│
├── app
│   ├── __init__.py
│   ├── api
│   ├── static
│   └── templates
├── config.py
└── run.py
         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-18 19:16

    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.

提交回复
热议问题