Wednesday, February 7, 2024

[SOLVED] Gcc error, No such file or directory "Python.h" -- installing pyAudio on centOS7

Issue

I have python 3.6.8 installed on CentOS7 and I'm trying to install pyaudio with

sudo python3.6 -m pip install pyaudio

This format worked to install a number of other things right beforehand, but if I try to use it here i get the following error

src/_portaudiomodule.c:28:10: fatal error: Python.h: No such file or directory
 #include "Python.h"
          ^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------

pip install pyaudio yeilds the same results

I have read the question and answer here but I still cannot figure it out

Any advice in installation? Thank you in advance!


Solution

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

It looks like pyaudio is compiling some C code who require Python.h, to fix your issue check this answer https://stackoverflow.com/a/21530768/9799292

(also, "pip install pyaudio" prints "bash: pip: command not found")

To fix this try to install pip by running this command

sudo yum install python3-pip


Answered By - Mathix420
Answer Checked By - Candace Johnson (WPSolving Volunteer)