Error:could not build wheel for pyaudio

I’m trying to deploy my streamlit app onto the cloud, but when installing the pyaudio in the requirements.txt file, it tells me.

ERROR: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects


I tried a specific version of pyaudio and also without specifying the version, but both didn’t work
I also tried including pip=22.3.1 did not work as well
Thanks in advace

1 Like

Can you link your repository so we can see your full requirements.txt and packages.txt? You will need items in your packages.txt file to tell the Debian environment what to install outside of the Python library packages.

See point 2, then scroll down to the bottom where it say apt-get dependencies for documentation:

thank you I looked into the documentation and put pyaudio in the packages.txt
it says

Update: I found some random code online and pasted it into the packages.txt, and it worked :joy: but my app is in the oven indefinitely. How long does it usually take?

You wouldn’t want to put the Python packages in packages.txt but the dependencies outside of Python there. I do see you have the correct list when I look at your GitHub from what I was able to find, also.

If you have been “stuck in the oven” for an hour, you may try manually rebooting the app. Sometimes with a change in environment, Streamlit Cloud needs a little encouragement to start fresh.

Thank you!

Hey im facing a similar issue. Deployed a web app using sounddevice library on the cloud. However streamlit shows as follows ( image attached) ( portaudio not found ). I have no issues with build and deploying. I tried adding a packages.txt with portaudio19-dev, libasound-dev
and libportaudio2 however it doesnt seem to solve the problem.

Im having the same problem @kevin866 would you mind update your solutions here ?

Hi @DuyquanDuc :wave:

From the official installation instructions, the solution is to add to your repo two files:





Once you add those files to your repo and reboot your app, you should be able to successfully import pyaudio without the ModuleNotFoundError and ERROR: Could not build wheels for PyAudio

1 Like

Thank you very much. This is indeed the solution, adding a packages.txt like you suggested solved my problems.

1 Like

After including the packages in the packages.txt , im encountering this error what should i do?

The virtual machine in which your application is running does not have a microphone. If you want to access the client’s microphone, maybe this component can help you:

I created packages.txt and able to deploy it but after deploying when i press record button i am getting this error

did you find any solution? I used packages.txt and requirments.txt as mentioned but still getting error
Collecting mdurl~=0.1
Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Building wheels for collected packages: PyAudio
Building wheel for PyAudio (pyproject.toml): started
Building wheel for PyAudio (pyproject.toml): finished with status ‘error’
error: subprocess-exited-with-error

× Building wheel for PyAudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-39
creating build/lib.linux-x86_64-cpython-39/pyaudio
copying src/pyaudio/ → build/lib.linux-x86_64-cpython-39/pyaudio
running build_ext
building ‘pyaudio._portaudio’ extension
creating build/temp.linux-x86_64-cpython-39
creating build/temp.linux-x86_64-cpython-39/src
creating build/temp.linux-x86_64-cpython-39/src/pyaudio
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include -I/usr/include -I/home/adminuser/venv/include -I/usr/local/include/python3.9 -c src/pyaudio/device_api.c -o build/temp.linux-x86_64-cpython-39/src/pyaudio/device_api.o
src/pyaudio/device_api.c:9:10: fatal error: portaudio.h: No such file or directory
9 | #include “portaudio.h”
| ^~~~~~~~~~~~~
compilation terminated.
error: command ‘/usr/bin/gcc’ failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for PyAudio
Failed to build PyAudio
ERROR: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects

Looks like portaudio19-dev is not installed.