Spectrum on AWS Lambda DistributionNotFound
Closed this issue · 2 comments
Hi,
I am hoping to get some help. I am building AWS Lambda function with pyHRV that uses spectrum. I am running into an error when deploying with Serverless Framework.
The error looks like this:
[ERROR] DistributionNotFound: The 'spectrum' distribution was not found and is required by the application
Traceback (most recent call last):
File "/var/task/serverless_sdk/__init__.py", line 128, in wrapped_handler
return user_handler(event, context)
File "/var/task/s_HQ_Analyser.py", line 23, in error_handler
raise e
File "/var/runtime/bootstrap.py", line 131, in handle_event_request
response = request_handler(event, lambda_context)
File "/var/task/serverless_sdk/__init__.py", line 128, in wrapped_handler
return user_handler(event, context)
File "/var/task/s_HQ_Analyser.py", line 23, in error_handler
raise e
File "/var/runtime/bootstrap.py", line 131, in handle_event_request
response = request_handler(event, lambda_context)
File "/var/task/serverless_sdk/__init__.py", line 128, in wrapped_handler
return user_handler(event, context)
File "/var/task/s_HQ_Analyser.py", line 23, in error_handler
raise e
File "/var/task/s_HQ_Analyser.py", line 18, in <module>
user_handler = serverless_sdk.get_user_handler('hq-analyser.main')
File "/var/task/serverless_sdk/__init__.py", line 54, 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 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/task/hq-analyser.py", line 16, in <module>
import pyhrv
File "/tmp/sls-py-req/pyhrv/__init__.py", line 36, in <module>
from pyhrv.hrv import hrv
File "/tmp/sls-py-req/pyhrv/hrv.py", line 47, in <module>
import pyhrv.frequency_domain as fd
File "/tmp/sls-py-req/pyhrv/frequency_domain.py", line 46, in <module>
import spectrum
File "/tmp/sls-py-req/spectrum/__init__.py", line 19, in <module>
from .datasets import *
File "/tmp/sls-py-req/spectrum/datasets.py", line 148, in <module>
dolphin_filename = spectrum_data("DOLPHINS.wav")
File "/tmp/sls-py-req/spectrum/datasets.py", line 137, in spectrum_data
info = pkg_resources.get_distribution('spectrum')
File "/tmp/sls-py-req/pkg_resources/__init__.py", line 482, in get_distribution
dist = get_provider(dist)
File "/tmp/sls-py-req/pkg_resources/__init__.py", line 358, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/tmp/sls-py-req/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/tmp/sls-py-req/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
I am not to sure what this error means and do not have much more info on this which makes it hard to debug. I was thinking that it might relate to Spectrum and how it gets installed in the environment. I am using serverless-python-requirements and docker to manage the python dependencies.
Apologies if this is not the right place to log an issue.
Any help or point in the right direction would be great.
Thanks
I know it's been a while, but I just saw your message. Did you find an answer? i don't think this error has to do with the spectrum package. I suspect that the problem has to do with how the dependencies are packaged into the lambda function. it looks like that within the lambda function, the code is trying to install dependencies.
Thank you for getting back to me, I appreciate it. I did manage to circumvent the problem, however, I can't remember exactly how unfortunately. I think if I remember correctly I just created a custom module with the functionality that I needed, which in the end did not depend on Spectrum.