I was installing a python module called pyaudio, and to my surprise, I got an error that says:
Usually, things go fine when you try to install modules using pip but sometimes, you might face this issue in some OS distributions.
If you quickly want to fix this error in windows, you can head to the unofficial python binaries for windows and download the pyaudio wheel for windows.
Next, head to your terminal and cd into the directory where you downloaded this wheel file. Type the following command in the terminal.
This command will install the pre-built wheel file to your computer, which means we don't need to build it from the source. The step which was creating an issue has been fixed by downloading this wheel binary.
The wheel file I downloaded was named PyAudio‑0.2.11‑cp37‑cp37m‑win32.whl, so I ran
and voila, the error is gone now.
Note: If you are a beginner and don't know what cd into a directory means. You can go to the folder where you downloaded this wheel file and press shift and right-click on some empty area to get an option called "Open command prompt/Powershell window here." This command will open the command prompt in the directory where you have downloaded this wheel file. Now you can type pip install Pyaudio-file-name.whl
If you are using Mac OS X, you can install the prerequisite portaudio library using homebrew by typing the following commands in the terminal:
Since homebrew takes care of portaudio installation, pyaudio will now be installed without any issues!
If you are an Ubuntu user, you can go to the terminal and install portaudio dev version using apt. Type the following command into the terminal to fix this error.
Make sure to install pyaudio using pip after installing portaudio. Happy coding!