Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Python.h" file not found on MACOSX, how to fix this?

`pip3 install PyAudio==0.2.12
Defaulting to user installation because normal site-packages is not writeable Collecting PyAudio==0.2.12 Using cached PyAudio-0.2.12.tar.gz (42 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: PyAudio Building wheel for PyAudio (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for PyAudio (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [16 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-39 copying src/pyaudio.py -> build/lib.macosx-10.9-universal2-cpython-39 running build_ext building '_portaudio' extension creating build/temp.macosx-10.9-universal2-cpython-39 creating build/temp.macosx-10.9-universal2-cpython-39/src clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c src/_portaudiomodule.c -o build/temp.macosx-10.9-universal2-cpython-39/src/_portaudiomodule.o src/_portaudiomodule.c:30:10: fatal error: 'Python.h' file not found #include "Python.h" ^~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for PyAudio Failed to build PyAudio ERROR: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects`

I want to use the speech recognition module. I downloaded portaudio via homebrew, but I am unable to download pyaudio.

like image 488
Raghav Singh Avatar asked Oct 23 '25 11:10

Raghav Singh


1 Answers

Export these from the command line terminal but change the path to be your correct path, then try again from the same command line terminal

export CPLUS_INCLUDE_PATH=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Headers
export C_INCLUDE_PATH=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Headers
like image 55
user1689987 Avatar answered Oct 25 '25 00:10

user1689987