Getting error from beanstalk when trying to deploy flask app: “no module named flask”
我已经试着解决这个问题有一段时间了,但还是搞不清楚。我的应用程序结构如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | myapp -application.py -myapp -sample.css -sample.js -blueprints.py -__init__.py -__init__.pyc -templates -base.jinja2 -node_modules -package.json -requirements.txt -static -venv -webpack.config.js |
我为Beanstalk提供了python 2.7环境,我的虚拟环境也同样如此。我在pip list和requirements.txt中有所有需要的包。来自eb config的yml文件中的wsgi路径设置为/myapp/application.py。我从eb日志中得到的确切错误是:
mod_wsgi(pid=2330):目标wsgi脚本'/opt/python/current/app/myapp/application.py'不能作为python模块加载。mod wsgi(pid=2330):处理wsgi脚本'/opt/python/current/app/myapp/application.py'时发生异常。"file/opt/python/current/app/cloud dev/application.py",第3行,位于
当我访问站点链接时,总是出现500个错误。非常感谢您的帮助!
我也遇到了同样的错误。对我有帮助的是将运行的flask对象重命名为"application":
1 2 3 4 5 6 7 | from flask import Flask application = Flask(__name__) # run the app. if __name__ =="__main__": application.run() |
来自亚马逊电子商务文档:
Using application.py as the filename and providing a callable application object (the Flask object, in this case) allows AWS Elastic Beanstalk to easily find your application's code.
号