Gunicorn 在启动 Flask 服务器时出现错误:
无法在 'wsgi' 中找到属性'app'。
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
#!/usr/bin/python3
from flask import Flask
app = Flask(__name__)
...
项目结构:
(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
我查看了(当应用程序名称从"application"更改后,Gunicorn找不到应用程序),但与我的情况无关,因为我已经使用了application
。
有什么想法是什么问题?
gunicorn your.wsgi:yourappname
,其中你需要将:yourappname替换为你在代码中创建的应用程序实例名称。 - Nam G VUgunicorn wsgi:app
命令来运行,而不是gunicorn wsgi
。我猜测后者会使用默认实例名称作为应用程序。 - Nam G VU