My Dream :)
I would like to use pyaudio
for a function which will be running on AWS Lambda. However, I get a PythonPipBuilder:ResolveDependencies
error when running sam build --use-container
My Setup
I've managed to build my project down to this.
requirements.txt
pyaudio
app.py
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': 'Hello World'
}
template.yaml (relevant pieces at least)
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: my_app/
Handler: app.lambda_handler
Runtime: python3.6
Events:
MyEvent:
Type: Api
Properties:
Path: /test
Method: get
My Problem
When running sam build --use-container --debug
I see this output:
Traceback (most recent call last): File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 42, in execute requirements_path=self.manifest_path, File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 137, in build_dependencies self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path) File "/var/lang/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 201, in build_site_packages raise MissingDependencyError(packages_without_wheels) aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {pyaudio==0.2.11(sdist)}
...
Build inside container returned response {"jsonrpc": "2.0", "id": 1, "error": {"code": 400, "message": "PythonPipBuilder:ResolveDependencies - {pyaudio==0.2.11(sdist)}"}}
My Theory
My theory is that this fails because PortAudio is not installed in the Docker container image used when running sam build --use-container
If I run pip install -r requirements.txt
on my local machine where I have PortAudio installed, everything works as expected.
My suspicion is that I need to install PortAudio in the AWS Lambda environment somehow...but how? Layers? And if so, from where do I get the binary files I need?
TL;DR;
How do I install PortAudio in an AWS Lambda environment?