-
[python] fatal error: Python.h: No such file or directorypython/errors and solved 2017. 11. 26. 14:52
"fatal error: Python.h: No such file or directory"
I tried to install pyaudio in raspberry Pi.
$ sudo pip install pyaudio
but the following error occurred.
Downloading/unpacking pyaudio
Downloading PyAudio-0.2.9.tar.gz (289kB): 289kB downloaded
Running setup.py (path:/tmp/pip-build-vnFPg1/pyaudio/setup.py) egg_info for package pyaudio
warning: no files found matching '*.c' under directory 'test'
Installing collected packages: pyaudio
Running setup.py install for pyaudio
building '_portaudio' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv7l-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-vnFPg1/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BIgurJ-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
copying src/pyaudio.py -> build/lib.linux-armv7l-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/src
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv7l-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-vnFPg1/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BIgurJ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-vnFPg1/pyaudio
Storing debug log for failure in /home/pi/.pip/pip.log
Solution
Install 'python-dev' first and install 'pyaudio' as shown below.
$ sudo apt-get install python-dev
$ sudo pip install pyaudio
Reference
'python > errors and solved' 카테고리의 다른 글
TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('S32') (0) 2017.11.26 [python] SyntaxError: Non-ASCII character (0) 2017.11.26 [python] ImportError: No module named requests (0) 2017.11.26