1

I am writing a program in Python, But I got an error

ModuleNotFoundError: No module named 'pyaudio'

Then I tried

pipwin install pyaudio

It came out

Requirement already satisfied: PyAudio==0.2.11 from file:///C:/Users/JIE_0305/pipwin/PyAudio-0.2.11-cp37-cp37m-win_amd64.whl

but I run the program again, it still

ModuleNotFoundError: No module named 'pyaudio'

How can I solve the problem?

Sih Jie
  • 241
  • 1
  • 3
  • 5
  • Do you happen to use a virtual environement? On the other hand: do you have several Python versions installed on your computer? Which version are you actually using? If you work on Jupyter, you should probably install the library pyaudio again in the notebook. – Catalina Chircu May 05 '20 at 03:22
  • I am not using a virtual environment. I have several Python versions installed on my computer and I am using Python3.7.3 – Sih Jie May 05 '20 at 05:33
  • OK, you should install the library when you are in your virtual environement. This must bea way to solve the problem. Otherwise you might have installed the library in another Python version than the one you use. Check this too. My advice is that you uninstall the library and then connect to your venv and install again. My guess. – Catalina Chircu May 05 '20 at 05:50
  • Are you on Windows or on Linux? – Catalina Chircu May 05 '20 at 05:54

3 Answers3

1

You could download the whl file and call it when installing, this might work, according to this post. In the post, you have the links to the site where you can download the whl file. It is also stated that it might work with Python 3.6 and not 3.7, try changing your Python version to 3.6, if the other options give not result.

Another solution is uninstalling pyaudio, then connecting to your virtual environement and install again withing your venv. It might solve your problem.

Sometimes it happens that a library successfully installed might be related to a Python version which is different than the one you used when running the program. You should check this also, I mean check to which Python version the pyaudio library is related. Use the same Python version in order to run the program.

Catalina Chircu
  • 1,506
  • 2
  • 8
  • 19
  • Thank you. I successfully installed pyaudio the way, but I run my program, it still run error like: ModuleNotFoundError: No module named 'pyaudio' – Sih Jie May 05 '20 at 06:26
  • Did you checked the link I sent you? Those people wrote they succeeded like that. – Catalina Chircu May 05 '20 at 09:17
0

Try refreshing first with

pipwin refresh

If not use pip instead

pip install pyaudio --> python2
pip3 install pyaudio --> python3
Jackson
  • 1,213
  • 1
  • 4
  • 14
  • Thank you. I tried. It didn't work. It run error like: ERROR: Command errored out with exit status 1 – Sih Jie May 05 '20 at 05:37
0

Please try to use the pip command instead.

python3 -m pip install pyaudio   # for python 3

or

python  -m pip install pyaudio   # for python 2 or lower