How to fix “Failed building wheel for pocketsphinx” on Debian Linux

Share this article

Initially, I was going to keep adding entries to the previous article, but I realized that it will quickly become too big. So, I decided to make a new article for each Linux problem.

Problem: Failed building wheel for pocketsphinx

programmer@dev-vm ~ $ sudo -H pip3 install pocketsphinx
Collecting pocketsphinx
 Using cached https://files.pythonhosted.org/packages/93/5f/a968e5d53d25e32deb78c3e169fd8612ecf53cc76e32cb40e19be35696af/pocketsphinx-0.1.3.tar.bz2
Building wheels for collected packages: pocketsphinx
 Running setup.py bdist_wheel for pocketsphinx ... error
 Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2fh3k1or/pocketsphinx/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/pip-wheel-7inrtxcb --python-tag cp35:
 running bdist_wheel
 running build_ext
 building 'sphinxbase._ad' extension
 swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
 swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
 creating build
 creating build/temp.linux-x86_64-3.5
 creating build/temp.linux-x86_64-3.5/swig
 creating build/temp.linux-x86_64-3.5/swig/sphinxbase
 creating build/temp.linux-x86_64-3.5/deps
 creating build/temp.linux-x86_64-3.5/deps/sphinxbase
 creating build/temp.linux-x86_64-3.5/deps/sphinxbase/src
 creating build/temp.linux-x86_64-3.5/deps/sphinxbase/src/libsphinxad
 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/include/python3.5m -c swig/sphinxbase/ad_wrap.c -o build/temp.linux-x86_64-3.5/swig/sphinxbase/ad_wrap.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/include/python3.5m -c deps/sphinxbase/src/libsphinxad/ad_pulse.c -o build/temp.linux-x86_64-3.5/deps/sphinxbase/src/libsphinxad/ad_pulse.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
 deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:30: fatal error: pulse/pulseaudio.h: No such file or directory
 compilation terminated.
 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 
 ----------------------------------------
 Failed building wheel for pocketsphinx
 Running setup.py clean for pocketsphinx
Failed to build pocketsphinx
Installing collected packages: pocketsphinx
 Running setup.py install for pocketsphinx ... error
 Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2fh3k1or/pocketsphinx/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-record-9d93xhta/install-record.txt --single-version-externally-managed --compile:
 running install
 running build_ext
 building 'sphinxbase._ad' extension
 swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
 swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
 creating build
 creating build/temp.linux-x86_64-3.5
 creating build/temp.linux-x86_64-3.5/swig
 creating build/temp.linux-x86_64-3.5/swig/sphinxbase
 creating build/temp.linux-x86_64-3.5/deps
 creating build/temp.linux-x86_64-3.5/deps/sphinxbase
 creating build/temp.linux-x86_64-3.5/deps/sphinxbase/src
 creating build/temp.linux-x86_64-3.5/deps/sphinxbase/src/libsphinxad
 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/include/python3.5m -c swig/sphinxbase/ad_wrap.c -o build/temp.linux-x86_64-3.5/swig/sphinxbase/ad_wrap.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/include/python3.5m -c deps/sphinxbase/src/libsphinxad/ad_pulse.c -o build/temp.linux-x86_64-3.5/deps/sphinxbase/src/libsphinxad/ad_pulse.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
 deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:30: fatal error: pulse/pulseaudio.h: No such file or directory
 compilation terminated.
 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 
 ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2fh3k1or/pocketsphinx/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-record-9d93xhta/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-2fh3k1or/pocketsphinx

Solution: In this particular instance of this error, I noticed toward the end of the output that a header file belonging to pulseaudio was missing. By installing the software it comes with, the error is resolved.

First, you need to make sure pulseaudio is installed. You can either manually check:

programmer@dev-vm ~ $ which pulseaudio
/usr/bin/pulseaudio

But you can bypass this step, because by including pulseaudio in the list of packages to install, it will be ignored if it’s already installed. To be honest, I didn’t bother taking the time to pinpoint exactly which package(s) contained the needed header file, so I installed several.

programmer@dev-vm ~ $ sudo apt-get install pulseaudio pulseaudio-utils libpulse-dev libpulse-java libpulse0

With those installed, you’re ready to install pocketsphinx with pip3 (the version I use).

programmer@dev-vm ~ $ sudo -H pip3 install pocketsphinx
Collecting pocketsphinx
 Using cached https://files.pythonhosted.org/packages/93/5f/a968e5d53d25e32deb78c3e169fd8612ecf53cc76e32cb40e19be35696af/pocketsphinx-0.1.3.tar.bz2
Building wheels for collected packages: pocketsphinx
 Running setup.py bdist_wheel for pocketsphinx ... done
 Stored in directory: /root/.cache/pip/wheels/38/80/4f/ddc3e8c2b788f2c7f1d625ae870f6bafd3038ff04a3445a2f8
Successfully built pocketsphinx
Installing collected packages: pocketsphinx
Successfully installed pocketsphinx-0.1.3
programmer@dev-vm ~ $ 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.