Solving ModuleNotFoundError: No module named ‘pyaudio’ – Python on Windows

ModuleNotFoundError: No module named ‘pyaudio’ – Python on Windows is a Python error which occurs when python cannot install a package.

In this article I am going to solve the error while I try explaining why the error is popping up in the first place, I will also introduce some solutions which worked for other developers and we will see if those solutions can solve the error in your unique situation.

Exploring the Error : ModuleNotFoundError: No module named ‘pyaudio’ – Python on Windows

First of all, let us check out how the message of the error looks like. Make sure yours looks like this in order to avoid all types of confusion.

                                                                       #
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyaudio'
                                                                       #

We get the error message after running a pyaudio installation the classic way. using pip install.

Just like in the command bellow

                                                                       #
pip install pyaudio # after this you can try importing pyaudio and the error will happen.
                                                                       #

In the sections bellow we will explain the root of the error more and propose some possible fixes.

Solution 1 : install pipwin.

First of all, you need to install pipwin. In order to install pipwin you need to use pip.

Install pipwin using pip just like in the command bellow.

                                                                       #
pip install pipwin
                                                                       #

Pipwin will install unofficial python packages and its a tool that complements pip in windows.

Now, try to install pyaudio using pipwin, you can do that by running the command bellow.

                                                                       #
pipwin install pyaudio
                                                                       #

This is a great alternative for python -m pip install pyaudio and should solve the problem for most people.

Bellow, is another solution you can try if this one does not work.

Solution 2 : use the py launcher.

The second solution is too install pyaudio in our case or any other package using the command bellow instead of the classic pip only command.

Run the following command.

                                                                       #
py -3.6 -m pip install <package> # py -3.6 -m pip install pyaudio in our case.
                                                                       #

Instead of using the command bellow.

                                                                       #
pip install <package># pip install pyaudio in our case.
                                                                       #

The reason you want to use the py launcher is to avoid using your system PATH used by python which usually causes this error. It is better to choose your python version directly.

I hope this guide solved your problem, thank you for reading.

Summing-up

The article is over guys, I hope my effort did not go to waste and I helped some of you solve this error, keep learning Python and keep coding, cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/