'Python-TensorFlow app FileNotFoundError: [Errno 2] No such file or directory
I am trying to test a simple Flask-TensorFlow Image Classifier app from docker container. The Docker containers were successfully deployed in an Ubuntu 22.10 EC2 instance. when I tried to hit /classify
endpoint the following errors have given:-
web_1 | 45.248.151.224 - - [13/May/2022 20:40:33] "POST /register HTTP/1.1" 200 -
web_1 | [2022-05-13 20:43:20,706] ERROR in app: Exception on /classify [POST]
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
web_1 | rv = self.dispatch_request()
web_1 | File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
web_1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
web_1 | File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 467, in wrapper
web_1 | resp = resource(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.10/site-packages/flask/views.py", line 84, in view
web_1 | return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
web_1 | resp = meth(*args, **kwargs)
web_1 | File "/usr/src/app/app.py", line 113, in post
web_1 | with open('text.txt') as f:
web_1 | FileNotFoundError: [Errno 2] No such file or directory: 'text.txt'
web_1 | 45.248.151.224 - - [13/May/2022 20:43:20] "POST /classify HTTP/1.1" 500 -
Here is my app.py code:-
Platform details:-
Python-3.10.4
pymongo-4.1.1
tensorflow-2.8.0
mongo:3.6.4
Ubuntu 22.10 EC2 Instance
Docker Engine - 20.10.14
This error never raised while I run the app in MacOS or in PC(Ubuntu-20.04). Only EC2 or Virtual Box Ubuntu 22.04 has given this error. Any Work around for this issue.TIA
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|