【问题标题】:AWS mod_wsgi error when deploying Flask with elasticbeanstalk使用 elasticbeanstalk 部署 Flask 时出现 AWS mod_wsgi 错误
【发布时间】:2015-11-01 04:39:51
【问题描述】:

在 elasticbeanstalk 上使用烧瓶时出现以下错误:

/opt/python/run/venv/bin/python3: can't open file 'mod_wsgi': [Errno 2] No such file or directory
[Sat Aug 08 23:43:35.994357 2015] [:error] [pid 7748] [remote 127.0.0.1:45363] mod_wsgi (pid=7748): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
[Sat Aug 08 23:43:35.994407 2015] [:error] [pid 7748] [remote 127.0.0.1:45363] mod_wsgi (pid=7748): SystemExit exception raised by WSGI script '/opt/python/current/app/application.py' ignored.
[Sat Aug 08 23:43:35.994449 2015] [:error] [pid 7748] [remote 127.0.0.1:45363] Traceback (most recent call last):
[Sat Aug 08 23:43:35.994511 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]   File "/opt/python/current/app/application.py", line 3, in <module>
[Sat Aug 08 23:43:35.994518 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]     app.run(debug=True)
[Sat Aug 08 23:43:35.994553 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]   File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 772, in run
[Sat Aug 08 23:43:35.994560 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]     run_simple(host, port, self, **options)
[Sat Aug 08 23:43:35.994590 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]   File "/opt/python/run/venv/lib/python3.4/site-packages/werkzeug/serving.py", line 623, in run_simple
[Sat Aug 08 23:43:35.994596 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]     reloader_type)
[Sat Aug 08 23:43:35.994624 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]   File "/opt/python/run/venv/lib/python3.4/site-packages/werkzeug/_reloader.py", line 231, in run_with_reloader
[Sat Aug 08 23:43:35.994630 2015] [:error] [pid 7748] [remote 127.0.0.1:45363]     sys.exit(reloader.restart_with_reloader())
[Sat Aug 08 23:43:35.994652 2015] [:error] [pid 7748] [remote 127.0.0.1:45363] SystemExit: 2

我正在使用 elasticbeanstalk 命令行界面来部署烧瓶应用程序。

【问题讨论】:

    标签: python amazon-web-services flask amazon-elastic-beanstalk


    【解决方案1】:

    您在生产中使用app.run。不要在生产中使用开发服务器。

    mod_wsgi 与任何 WSGI 应用服务器一样,希望在导入时找到 application 实例,但您正在运行开发服务器。

    防止在导入时运行开发服务器。根据您的 mod_wsgi 设置,它可能还需要名称 application 而不是 app

    application = app
    
    if __name__ == '__main__':
        app.run()
    

    【讨论】:

      猜你喜欢
      • 2020-08-24
      • 2016-11-14
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      • 2014-09-03
      • 2021-09-16
      • 1970-01-01
      • 2014-06-28
      相关资源
      最近更新 更多