I just installed Rocky Linux 9 and my os contains "Development Tools" packages plus the required libraries for development and installing PyAudio such as portaudio and portaudio-devel, which is mentioned many times for other distros such as Ubuntu and RHEL.
By the way, I could not install PyAudio via mentioned ways on Rocky Linux 9. The error message during installation is that:
╰─ pip install pyaudio ─╯
Collecting pyaudio
Using cached PyAudio-0.2.13.tar.gz (46 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
╰─> [19 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/__init__.py -> 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 -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I/usr/include -I/home/amirmasoud/.virtualenvs/Real-Time-Voice-Cloning-Spanish/include -I/usr/include/python3.9 -c src/pyaudio/device_api.c -o build/temp.linux-x86_64-cpython-39/src/pyaudio/device_api.o
In file included from src/pyaudio/device_api.c:1:
src/pyaudio/device_api.h:7:10: fatal error: Python.h: No such file or directory
7 | #include "Python.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
I searched around the problem and I am tackling it with that. Thereby, the following mentioned ways are among my efforts.
The one way I tried to fix that but not worked is that installing portaudio and portaudio-devel. Another way was installing in the new Python virtualenv, however, it is clear that has not worked yet. I also tried to install it by cloning its repository to utilize a different way of installing with pip. It has not worked either.
sudo yum install python3-devel
. The key to solving your problem is to understand what the filePython.h
is, what it is used for, and why it is missing from your system. When you see lines that start withgcc
, that means that the package requires compilation and parts of the package are written in C or C++.python-dev
contains the header files you need to build Python packages and extensions that are written in C or C++. This link will help you learn more.