简体   繁体   English

Gunicorn:尝试启动 flask 服务器时无法在 'wsgi' 中找到属性 'app'

[英]Gunicorn: Failed to find attribute 'app' in 'wsgi' when attempting to start flask server

Gunicorn fails to start flask server with the error: Failed to find attribute 'app' in 'wsgi'. Gunicorn 无法启动 flask 服务器并出现错误: Failed to find attribute 'app' in 'wsgi'. . .

The wsgi.py wsgi.py

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/root/customer-account-automation/")

from app import app as application
if __name__ == "__main__":
    application.run()

app.py应用程序.py

#!/usr/bin/python3
from flask import Flask
app = Flask(__name__)
...

Project structure:项目结构:

(customer-account-automation) root@jsd-user-management:~/customer-account-automation# tree
.
├── Pipfile
├── Pipfile.lock
├── README.md
├── __pycache__
│   ├── app.cpython-37.pyc
│   └── wsgi.cpython-37.pyc
├── app.py
├── customerAccountMgmt.py
├── get-pip.py
├── static
│   ├── app.js
│   ├── bulma.min.css
│   ├── highlight.min.css
│   ├── highlight.min.js
│   └── styles.css
├── templates
│   ├── 404.html
│   ├── base.html
│   ├── change_password.html
│   ├── create_user.html
│   ├── deactivate_user.html
│   └── login.html
└── wsgi.py

I checked ( Gunicorn can't find app when name changed from "application" ) but it doesn't relate to mine as I already use the application .我检查了( 当名称从“应用程序”更改时,Gunicorn 找不到应用程序)但它与我的无关,因为我已经使用了该application

Any ideas what could be the problem?任何想法可能是什么问题?

Gunicorn is looking for app in wsgi so change Gunicorn 正在寻找 wsgi 中的应用程序所以改变

from app import app as application
if __name__ == "__main__":
    application.run()

to

from app import app as application
app = application

Then you can run do...which is what i am guessing you are doing然后你可以运行 do...这就是我猜你正在做的事情

gunicorn <all the options here> wsgi:app

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 python flask 应用程序部署到 heroku 时 Procfile / wsgi 出现问题 ~ 找不到属性 - Problem with Procfile / wsgi when deploying to heroku with python flask app ~ Failed to find attribute 在 Heroku 上部署 Postgres Flask 应用程序,“gunicorn.errors.AppImportError:无法在 'app' 中找到属性 'app'。” - Deploying Postgres Flask App on Heroku, "gunicorn.errors.AppImportError: Failed to find attribute 'app' in 'app'." 当我在gunicorn上运行Flask应用程序时设置app.wsgi_app = ProxyFix(app.wsgi_app)会发生什么? - What is going on when I set app.wsgi_app = ProxyFix(app.wsgi_app) when running a Flask app on gunicorn? 带有 wsgi 的 gunicorn 问题的烧瓶 - Flask with gunicorn problems with wsgi 使用gunicorn作为wsgi服务器将请求记录到Flask服务器上……到AWS CloudWatch - Log requests to a flask server using gunicorn as wsgi server … to AWS cloudwatch Flask 引发在 Gunicorn 等 WSGI 服务器上运行的“地址已在使用” - Flask raises `Address already in use` running with a WSGI server such as Gunicorn Gunicorn 20 在 'index' 中找不到应用程序 object 'app.server' - Gunicorn 20 failed to find application object 'app.server' in 'index' 使用 gevents Wsgi 服务器在进程中多次启动和停止烧瓶应用程序 - Start and Stop a flask app multiple times within a process using gevents Wsgi server 在“ app” gunicorn中找不到应用程序对象“ app” - Failed to find application object 'app' in 'app' gunicorn 金枪鱼无法启动烧瓶 - gunicorn cannot start flask
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM