본문 바로가기

리눅스/문제해결

fatal error: Python.h: No such file or directory

아래와 같이 명령어를 입력하여

pyaudio를 설치하려 했다.

그러자 엄청난 에러가 발생했다.

$ sudo pip install pyaudio



에러들....

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


해결책은 아래와 같이 python-dev를 먼저 설치해주면 된다.


$ sudo apt-get install python-dev