gpt4 book ai didi

python - 将 Flask 应用程序导入 Elastic Beanstalk 错误 : can't open file 'mod_wsgi' : [Errno 2] No such file or directory

转载 作者:太空宇宙 更新时间:2023-11-03 14:47:55 24 4
gpt4 key购买 nike

我尝试将 Flask 应用程序放在 Elastic Beanstalk(Amazon Web Services、EC2)上,但上传文件后收到 500 错误。对可能出现的问题有什么想法吗?错误日志:

/opt/python/run/venv/bin/python3: can't open file 'mod_wsgi': [Errno 2] No such file or directory
[Fri Sep 08 03:23:05.754341 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] mod_wsgi (pid=13619): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
[Fri Sep 08 03:23:05.754577 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] mod_wsgi (pid=13619): SystemExit exception raised by WSGI script '/opt/python/current/app/application.py' ignored.
[Fri Sep 08 03:23:05.754729 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] Traceback (most recent call last):
[Fri Sep 08 03:23:05.754992 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] File "/opt/python/current/app/application.py", line 11, in <module>
[Fri Sep 08 03:23:05.755007 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] application.run(debug=True)
[Fri Sep 08 03:23:05.755116 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] File "/opt/python/run/venv/lib/python3.4/site-packages/flask/app.py", line 772, in run
[Fri Sep 08 03:23:05.755131 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] run_simple(host, port, self, **options)
[Fri Sep 08 03:23:05.755242 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] File "/opt/python/run/venv/lib/python3.4/site-packages/werkzeug/serving.py", line 737, in run_simple
[Fri Sep 08 03:23:05.755257 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] reloader_type)
[Fri Sep 08 03:23:05.755344 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] File "/opt/python/run/venv/lib/python3.4/site-packages/werkzeug/_reloader.py", line 265, in run_with_reloader
[Fri Sep 08 03:23:05.755358 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] sys.exit(reloader.restart_with_reloader())
[Fri Sep 08 03:23:05.755429 2017] [:error] [pid 13619] [remote 128.12.244.5:31824] SystemExit: 2

我的文件结构如下: file hierarchy

我的 WSGI 路径是 config

最佳答案

结果我需要将 application.run() 包装在 if __name__ == '__main__': block 中。这可确保默认情况下不加载本地 WSGI 服务器。

来源:http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/

关于python - 将 Flask 应用程序导入 Elastic Beanstalk 错误 : can't open file 'mod_wsgi' : [Errno 2] No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46109548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com