speech_recognition: Install/compilation of PyAudio failed
Kubuntu 17.10.1 Python 3.6.3 Pip 9.0.1
Created a virtual environment and read through the SpeechRecognition instructions. Here are the steps
$ sudo apt-get install python-pyaudio python3-pyaudio
that went okay, it also installed libportaudio2
$ sudo apt-get install python3 python3-all-dev python3-pip build-essential swig git libpulse-dev
Apt also added the suggestions - “The following NEW packages will be installed: libglib2.0-dev libglib2.0-dev-bin libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpulse-dev libpython3-all-dev pkg-config python3-all python3-all-dev swig swig3.0”
Then installed SpeechRecognition
$ pip install SpeechRecognition
Then tried SpeechRecognition and got an error
$ python3 -m speech_recognition Traceback (most recent call last): File “…/SpeechRecognition/lib/python3.6/site-packages/speech_recognition/init.py”, line 108, in get_pyaudio import pyaudio ModuleNotFoundError: No module named ‘pyaudio’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main “main”, mod_spec) File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code exec(code, run_globals) File “…/SpeechRecognition/lib/python3.6/site-packages/speech_recognition/main.py”, line 4, in <module> m = sr.Microphone() File “…/SpeechRecognition/lib/python3.6/site-packages/speech_recognition/init.py”, line 79, in init self.pyaudio_module = self.get_pyaudio() File “…/SpeechRecognition/lib/python3.6/site-packages/speech_recognition/init.py”, line 110, in get_pyaudio raise AttributeError(“Could not find PyAudio; check installation”) AttributeError: Could not find PyAudio; check installation
Tried installing PyAudio , even though it is already installed via Apt
$ pip3 install pyaudio Collecting pyaudio Downloading PyAudio-0.2.11.tar.gz Building wheels for collected packages: pyaudio Running setup.py bdist_wheel for pyaudio … error Complete output from command …/SpeechRecognition/bin/python3 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-72_au_03/pyaudio/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” bdist_wheel -d /tmp/tmpu_qg0ulxpip-wheel- --python-tag cp36: usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …] or: -c --help [cmd1 cmd2 …] or: -c --help-commands or: -c cmd --help
error: invalid command ‘bdist_wheel’
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 …/SpeechRecognition/bin/python3 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-72_au_03/pyaudio/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-feocjwqu-record/install-record.txt --single-version-externally-managed --compile --install-headers …/SpeechRecognition/include/site/python3.6/pyaudio: running install running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying src/pyaudio.py -> build/lib.linux-x86_64-3.6 running build_ext building ‘_portaudio’ extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/src x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I…/SpeechRecognition/include -I/usr/include/python3.6m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.6/src/_portaudiomodule.o src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or directory #include “portaudio.h” ^~~~~~~~~~~~~ compilation terminated. error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
Command “…/SpeechRecognition/bin/python3 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-72_au_03/pyaudio/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-feocjwqu-record/install-record.txt --single-version-externally-managed --compile --install-headers …/SpeechRecognition/include/site/python3.6/pyaudio” failed with error code 1 in /tmp/pip-build-72_au_03/pyaudio/
This appears to be the same problem - https://github.com/SlapBot/stephanie-va/issues/8 . I will try the solution at https://github.com/SlapBot/stephanie-va/issues/8#issuecomment-307617796
Not sure if the following had an impact or not. The apt commands I used were run within a virtual environment, but I would have thought anything to do with Kubuntu packages would be system wide. I installed SpeechRecognition with pip
instead of pip3
(I don’t think it matters).
Although if I run pip3 or pip within the virtual environment, they both say version 9.0.1, yet if I run them both outside the virtual environment, it shows pip3 is installed but not pip.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (1 by maintainers)
Tried those apt commands ( I left our libportaudio2 as apt informed me it was already installed)
$ sudo apt install libasound-dev portaudio19-dev libportaudiocpp0
which resulted in
Back to the VE, and although building the wheel fails, installed PyAudio
$ pip3 install pyaudio
Try the SpeechRecognition again
$ python3 -m speech_recognition
Seems to fix it. The readme at https://github.com/Uberi/speech_recognition/blob/master/README.rst needs updating to reflect the additional packages required (if PyAudio is to be used)
I got the same error, and I found that the file “portaudio.h” was truly missing. So i first use
brew install portaudio
and thenpip install pyaudio
. These work for me. If those commands still not work ,maybe this may help.ubuntu: 1、sudo apt install portaudio19-dev python-pyaudio 2、pip install PyAudio
I’m getting the error: error: option -I not recognised
😦
Installing collected packages: pyaudio Running setup.py install for pyaudio … error ERROR: Command errored out with exit status 1: command: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/tmp/pip-install-XVUtNc/pyaudio/setup.py’“'”‘; file=’“'”‘/private/tmp/pip-install-XVUtNc/pyaudio/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ -I/path/to/the/dir/of/portaudio.h install --record /private/tmp/pip-record-MiW3OF/install-record.txt --single-version-externally-managed --compile cwd: /private/tmp/pip-install-XVUtNc/pyaudio/ Complete output (6 lines): usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …] or: setup.py --help [cmd1 cmd2 …] or: setup.py --help-commands or: setup.py cmd --help
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/tmp/pip-install-XVUtNc/pyaudio/setup.py’“'”‘; file=’“'”‘/private/tmp/pip-install-XVUtNc/pyaudio/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ -I/path/to/the/dir/of/portaudio.h install --record /private/tmp/pip-record-MiW3OF/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Hi to everyone,
I think I had the same issue with PyAudio. The one where somehow there is a missing header file. I was able to solve it with something like
This basically injects header files to the build process while installing something with pip.
While following @palikar i’m getting same error as @mertcanaltin gets
error: option -I not recognised
errro… in windows… its not working