Unable to install PyAudio library on the Nvidia AI workbench

If you are reporting a bug or error, consider submitting a Support Bundle to aiworkbench-ea@nvidia.com. This will help us solve your issue more quickly.

Please describe your issue or request: (tick the boxes after creating this topic):

Please tick the appropriate box to help us categorize your post
[*] Bug or Error
Feature Request
Documentation Issue
Other

Hi All,
I’m trying to install the PyAudio library on Nvidia AI workbench . I did a import of the PyAudio in my python script . I got an error saying pyaudio module not found. So then I tried installing it manually for which I did a pip install PyAudio and I got some errors as highlighted below.

//===================================================
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) … error
error: subprocess-exited-with-error

× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
/tmp/pip-build-env-kbvgtbj7/overlay/local/lib/python3.10/dist-packages/_distutils_hack/init.py:54: UserWarning: Reliance on distutils from stdlib is deprecated. Users must rely on setuptools to provide the distutils module. Avoid importing distutils or import setuptools first, and avoid setting SETUPTOOLS_USE_DISTUTILS=stdlib. Register concerns at Sign in to GitHub · GitHub
warnings.warn(
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/pyaudio
copying src/pyaudio/init.py → build/lib.linux-x86_64-3.10/pyaudio
running build_ext
building ‘pyaudio._portaudio’ extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
creating build/temp.linux-x86_64-3.10/src/pyaudio
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/include -I/usr/include -I/usr/include/python3.10 -c src/pyaudio/device_api.c -o build/temp.linux-x86_64-3.10/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/x86_64-linux-gnu-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: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyaudio)

Any suggestions ?

Br,
Raghu

Add your PyAudio wheel build to the postBuild.bash so you have full sudo access during the build. This will force PyAudio to be compiled during the container build process. This is the first time PyAudio has been integrated into a Workbench container please keep us aware of your progress.

Could you please provide more details as to what I need to add in the postBuild.bash? Usually, when I install PyAudio locally in my windows machine I do not have to install any other dependencies , I just do a “pip install pyaudio” and import it. Why is this not included in the AI workbench? Is this not a basic library? I also have code in my Jupyter notepad should I commit that into the git before modifying the code in the postbuild.bash? And let’s say I have edited the file “postbuild.bash”, how do I build it with the new changes? I see the build icon but I’m not able to click on it!!

Br,
Raghu

Hi - sorry for the delay.

I googled instructions to install pyaudio on ubuntu (there seems to be a dependency) and then i used the environment manager to install.

it worked.

See the attached video.

Does this clear it up for you?

1 Like

Hi,
Thanks for the video . It worked as expected. I was trying out these commands on the CLI terminal for which it was asking me a sudo password . But with the way it was done in the video was more clear and I was also able to import ffpmeg.

Thank you very much for the help!!!

Br,
Raghu

1 Like

Great!!

Should be MORE great, a video about building a custom environment, even for those NVIDIA CARDS not supported as my case -GT 710-

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.