Hi,
I have been trying to get a Flask app using numpy running with sls.
I used the Flask template from SLS to create the app.
Added my additional dependencies to requirements.txt
which looks like following:
flask==3.0.0
markupsafe==2.1.3
numpy==1.21.0
pillow==10.1.0
pyvips==2.2.1
requests==2.31.0
werkzeug==3.0.1
I can run it locally using
sls wsgi serve
When I deploy, it successfully deploys
But when I run it shows error like following
Unable to import app.app
GTKkiJlcmbt0G5P9moaFcOZwd2Yu1LVW6kMBfzmEblfLAFwvdEwk3PQZcZbEaOsLMMw49Jl9SJcEM9q5Q8tjmPRYUh4SfwbWyQuGHlN7nqAlvGlo3cybpFzNsSdHpssxf8LkNMAucBbUbqJo8yppntHG2QyaNuyQSvO1F5lW7LqULwDNlp+Pm2OlTX2m3iwqZL1+kY4lErG0+rY678Ny4gkK2ylqqkrlQAwrSuFCDxRl+/He7pPB1s6gB3uP+lv7fXjS37oHgwfb+3B/9wls3Xu2fbcPuzvwYPc5DHZhf/fRs352f3t//2n/hpJDJrKVaFbqKdytJiUSCpQoAS7BaBwVBiNPQDrBUJRCVLsowrJwGVeQ8Qk2MxG4fBPVD7eCE2fTS4iYCkgqAiYs5iCw5yNAjBEbw04c7E1gTITihUJi6aAdRXlOERyVE1MZJaZBsCD9F6Bi5mZQSx2QnMU4JcUI6zENwIvwhkQxTSgcSRmJXi0jX2V8WMODjMNsUYvxDFY7tbmaZTCb0CMZ+Iqy56MtpIRJmpqzRxTVOWHJZb7PxrgrNbWB1FDYS9UQcEIltGHgvfwSCmRWJQX5tLxwLp+lGUbGRxGipKkNTa2XFCXxICCHFETMkdoRkYkrEyDpPzrdJRKasZEjakt1GoKNi9zY9ycgZOxM0vXIRBzghEmPSkkhonzkIwtzCm7M01k1on6EOdnl3tBDycgLAFO2/Jj87+cki2ROc21+7DbxsGhmh0UTj921pPR4SsWi5tQ7WdNPp2w+uASGh0M0qaTpnTIOplBuYqGGEtunskAHCk4klhdpTCsbVGOetJdzymo6Lpe1ifPfK571siGU5vEkfCo5p+SLx6H0Alqbj+iCr0ZGTQZipq6g3r/ChpdTmiKsyOS0kV8+7Xeehvfd/ycy1810FUveKvInqO+qM0eKbG7CmXReVtJlJV1W0v+jkhZDLDibFb1CYk5GqiZnyRN+r594msq/1z+MM91I3TltY+7Wqeew6dNX4Z6ZTNXLZ6/LZ69/4dnrjPcGmqa/30XpWuz8ea3inzJ2t+sNK0u8k+gseieRNfjsxVe59N6LrzdvSyoeSPEMmds8KOHm0stKRZlt68FZ78sUuLJx9c3bvwB8gxzVqxUAAA==
[ERROR] Exception: Unable to import app.app
Traceback (most recent call last):
File "/opt/python/serverless_aws_lambda_sdk/instrument/__init__.py", line 598, in stub
return self._handler(user_handler, event, context)
File "/opt/python/serverless_aws_lambda_sdk/instrument/__init__.py", line 580, in _handler
result = user_handler(event, context)
File "/var/task/serverless_sdk/__init__.py", line 144, in wrapped_handler
return user_handler(event, context)
File "/var/task/s_api.py", line 25, in error_handler
raise e
File "/var/runtime/bootstrap.py", line 160, in handle_event_request
response = request_handler(event, lambda_context)
File "/opt/python/serverless_aws_lambda_sdk/instrument/__init__.py", line 598, in stub
return self._handler(user_handler, event, context)
File "/opt/python/serverless_aws_lambda_sdk/instrument/__init__.py", line 580, in _handler
result = user_handler(event, context)
File "/var/task/serverless_sdk/__init__.py", line 144, in wrapped_handler
return user_handler(event, context)
File "/var/task/s_api.py", line 25, in error_handler
raise e
File "/var/runtime/bootstrap.py", line 160, in handle_event_request
response = request_handler(event, lambda_context)
File "/opt/python/serverless_aws_lambda_sdk/instrument/__init__.py", line 598, in stub
return self._handler(user_handler, event, context)
File "/opt/python/serverless_aws_lambda_sdk/instrument/__init__.py", line 580, in _handler
result = user_handler(event, context)
File "/var/task/serverless_sdk/__init__.py", line 144, in wrapped_handler
return user_handler(event, context)
File "/var/task/s_api.py", line 25, in error_handler
raise e
File "/var/task/s_api.py", line 20, in <module>
user_handler = serverless_sdk.get_user_handler('wsgi_handler.handler')
File "/var/task/serverless_sdk/__init__.py", line 56, in get_user_handler
user_module = import_module(user_module_name)
File "/var/lang/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/task/wsgi_handler.py", line 115, in <module>
wsgi_app = import_app(config)
File "/var/task/wsgi_handler.py", line 48, in import_app
raise Exception("Unable to import {}".format(config["app"]))END RequestId: 755d9fef-5588-47b9-9e72-6e10dfc55fc5
REPORT RequestId: 755d9fef-5588-47b9-9e72-6e10dfc55fc5 Duration: 9.80 ms Billed Duration: 10 ms Memory Size: 1024 MB Max Memory Used: 77 MB
I have tried cleaning up my env and trying different python versions from 3.12 to 3.8