I want to use the SpeechRecognition library for Python, but when I try to run a program that uses the microphone, which I intend to do, I get the error
“PyAudio 0.2.11 or later is required (found version 0.2.9)”
So I did some digging and found how to install that using apt-get. Unfortunately I run Fedora 26, so I have to use yum to install my packages, and when I looked for ways to install PyAudio using that, I was only able to find version 0.2.9.
Whenever I try to do
pip install pyaudio
I get the following error:
Failed building wheel for pyaudio Running setup.py clean for pyaudio Failed to build pyaudio Installing collected packages: pyaudio Running setup.py install for pyaudio … error Complete output from command /usr/bin/python2 -u -c “import setuptools, tokenize;file=’/tmp/pip-build-ZiuxD3/pyaudio/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))” install –record /tmp/pip-a2Iwxv-record/install-record.txt –single-version-externally-managed –compile: running install running build running build_py creating build creating build/lib.linux-x86_64-2.7 copying src/pyaudio.py -> build/lib.linux-x86_64-2.7 running build_ext building ‘_portaudio’ extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/src gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory error: command ‘gcc’ failed with exit status 1
----------------------------------------
Command “/usr/bin/python2 -u -c “import setuptools, tokenize;file=’/tmp/pip-build-ZiuxD3/pyaudio/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))” install –record /tmp/pip-a2Iwxv-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-ZiuxD3/pyaudio/
Advertisement
Answer
You need:
sudo dnf install portaudio-devel redhat-rpm-config
Next, you can install pyaudio.
pip install --user pyaudio
Note:
- yum is deprecated, use dnf instead.
- When you see compilation/building about a program, always check you have the devel dependencies like package_name-devel.
- when installing with pip on fedora, always use –user. It will install package in your home. Else, you can create conflict with dnf packages.