Struggling to Use PyAudio on AWS Lambda
Asked by
+ramp access!
Hey everyone! I'm having trouble getting the PyAudio library to work on AWS Lambda. I keep running into an error saying there's no module named 'pyaudio_portaudio', even though I've added the PyAudio layer along with PortAudio. Has anyone else dealt with this issue or know how to resolve it? Any advice would be appreciated! Thanks!
Answers
Here are a few things to check:
- Make sure that the architecture you've selected for your layer is compatible with your Lambda runtime.
- You can't just install PyAudio locally on your Mac or Ubuntu and upload it; it needs to be compiled in an Amazon Linux 2 environment which matches the Lambda environment.
- The error 'ModuleNotFoundError: No module named pyaudio_portaudio' usually indicates that the shared object file `libportaudio.so` is missing or not in the right place, so checking for that is a good idea.
- Are you using a native layer or one created with Docker? That might play a role too.
Reply to this answer
Add your answer
Answers are reviewed before publication.
202 pantry labels: I tried installing it locally on Windows and uploaded it to Lambda, but I ran into the same issue. I also created zip deployment packages with native libraries using a command that includes the manylinux2014_x86_64 specification. Still no luck! If I install PyAudio using pip on Windows, how can I compile it for the Linux 2 environment to match the Lambda runtime? I'm not very familiar with Linux and Docker. Thanks for any help!