Error message in web.stdout.log:
Oct 15 13:03:29 ip-172-31-18-218 web: ModuleNotFoundError: No module named 'application'
Oct 15 13:03:29 ip-172-31-18-218 web: [2020-10-15 13:03:29 +0000] [4633] [INFO] Worker exiting (pid: 4633)
Oct 15 13:03:29 ip-172-31-18-218 web: [2020-10-15 13:03:29 +0000] [4626] [INFO] Shutting down: Master
Oct 15 13:03:29 ip-172-31-18-218 web: [2020-10-15 13:03:29 +0000] [4626] [INFO] Reason: Worker failed to boot.
Error message in nginx/error.log
2020/10/15 13:04:21 [error] 4559#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.42.151, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.18.218"
Flask app:
# EB looks for an 'application' callable by default.
application = Flask(__name__)
@application.route('/')
def home():
return "Hello World"
@application.route('/processImage')
def index():
[Some Code...]
if __name__ == '__main__':
# Setting debug to True enables debug output. This line should be
# removed before deploying a production app.
application.run('localhost',8000,debug=True)
requirements.txt
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
Flask==1.1.2
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
numpy==1.19.2
opencv-python==4.4.0.44
requests==2.24.0
urllib3==1.25.10
Werkzeug==1.0.1
My folder structure:
eb-flask
|- .vscode (folder)
|- images (folder)
|- application.py
|- requirements.txt
Way of deployment:
Deployment via the Elastic Beanstalk Web UI by uploading a .zip archive of the above described folder.
Any ideas on how to further debug or solve this would be highly appreciated. Thanks a lot in advance.
You might need to add the modules to the environments path variable so that the module lookup is sucessful. Run the following from a file/ command line-
import sys
import os
sys.path.append("/path_to_your_app/eb-flask")
您正在端口 8000 上运行您的应用程序。但是,EB 会期望它在端口 5000 上运行。因此,您要么更改 EB 上的默认端口,要么修改您的应用程序以在端口 5000 上运行:
application.run('localhost', 5000,debug=True)
I was getting the same error.
Few things I did was:
application = app = Flask(__name__)
.application.py
.Also very important: whatever files are required select those and zip them (right-click "send to" -> "compressed" in windows) and upload to the beanstalk.
DO NOT put all the required files in a folder and zip. This was the reason behind ModuleNotFound: No Module name 'application'
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.