In this article, I will be sharing with you how to solve one of the most annoying problems, python coders have to suffer from- "Error installing PyAudio"
PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. With PyAudio, you can easily use Python to play and record audio on a variety of platforms.This module is a dependence of Speech Recognition module in python. This error is very irritating when you are building a voice assistant and the computer can't use speech recognition
The error actually happens because when we install PyAudio from PIP, it fails to install _portaudio bindings and several build tools for it which is severe dependence for PyAudio to work.
Fatal Error: Cannot open include file 'portaudio.h' :'No such file in directory'
How to solve it?
Follow the given steps:-
- First uninstall the error version of PyAudio by running the following command in powershell:-
- pip uninstall pyaudio
- Go to unofficial python binaries
- Press CTRL+F and type pyaudio
- Click on PyAudio and then download the appropriate .whl file according to the installed version of python in your system.
- Go to the download folder on your pc and find where it was downloaded.
- Open Powershell on the same window.
- Type "pip install pya" and press tab, it will autocomplete
- Press Enter
- Bingo pyaudio has been successfully installed
- To test this open python and run any program involving pyaudio and you won't get any error.
- Best of luck for your voice assistant!
- Happy Coding!