1

I'm trying to install PyAudio for an application to record audio clips from microphone input. I installed PyAudio from executable file (Windows 7, python 2.6). However when I try to import this library in my code, I get the following error.

Please build and install the PortAudio Python bindings first.

I tried the solution provided at Python PyAudio installation problems (with PortAudio) but I got the following error message when I installed it using the executable given at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio

Traceback (most recent call last):
  in <module>
    import pyaudio
  File "C:\Python26\lib\site-packages\pyaudio.py", line 99, in <module>
    import _portaudio as pa
ImportError: DLL load failed: %1 is not a valid Win32 application.

I tried building the PortAudio v19 but It also did not work for me. I'm stuck at this point and I'll appreciate any help in this regard.

Community
  • 1
  • 1
codeMonk
  • 11
  • 1
  • 3

2 Answers2

0

For this you need to first install brew. Check this link. Then, write in your command

brew install portaudio

Once portaudio is installed, run

pip install python-pyaudio
Antoine Boisier-Michaud
  • 1,575
  • 2
  • 16
  • 30
Prateek Saini
  • 346
  • 3
  • 8
0

I tried to install pyaudio into my project in different ways. But it did not work out and I finally found a way to do it. First I went to this link (https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio) and downloaded the .whl file related to my Python version.

How to find correct .whl file?

  1. type python in cmd.
  2. result will be following

result of commanding "python" in cmd

  1. using above result you can find python version and bit value

  2. using those data download the required .whl file

  3. in above example it was - PyAudio-0.2.11-cp310-cp310-win_amd64.whl

After downloading required .whl file, copy the path of that file

ex - C:\Users\Lahiru\Downloads\PyAudio-0.2.11-cp310-cp310-win_amd64.whl

Then go to the Python project and open the terminal and run following.

pip install C:\Users\Lahiru\Downloads\PyAudio-0.2.11-cp310-cp310-win_amd64.whl

If the installation is successful, Hurray. Now you can use pyaudio.