Facing problem in installing PyAudio in Azure App Service

Anonymous
2022-07-28T15:19:17.123+00:00

I have created a web application which uses PyAudio library. I have tried deploying it using the local git, everytime I am facing issue in deployment. While in deploying I am facing error in building wheel showing some PEP 517 error. Later I tried installing PyAudio separately using SSH, Below I am attaching the log:

(antenv) root@ec381d74a970:# pip install PyAudio
Collecting PyAudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
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
╰─> [11 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
copying src/pyaudio.py -> build/lib.linux-x86_64-3.7
running build_ext
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include -I/usr/include -I/tmp/8da6a7643276f67/antenv/include -I/opt/python/3.7.12/include/python3.7m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.7/src/_portaudiomodule.o
error: command 'gcc' failed: No such file or directory: 'gcc'
[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

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,935 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2022-08-04T18:44:00.81+00:00

    Hi @Anonymous ,

    You're getting error because gcc package is part of the image app service uses. There are two options though to get around this:

    1. Use the pip command. To do this, you will need to install the compiler and other build tools first, then the PortAudio library that PyAudio depends on. You can use something like apt install build-essential portaudio19-dev followed by pip install PyAudio.
    2. You could actually use your own custom image with any tool and library dependencies your application needs and pull the image from either docker hub or Azure Container Registry.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.