1

Windows version: 19.0.19041

Python version: 3.9

I am trying to install PyAudio on Pycharm but it always give error

I installed PyAudio in cmd but when i run on cmd it gives error like this:

Traceback (most recent call last):
  File "C:\Users\mt7da\alexa", line 5, in <module>
    with sr.Microphone() as source:
  File "C:\Users\mt7da\AppData\Local\Programs\Python\Python39\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
    self.pyaudio_module = self.get_pyaudio()
  File "C:\Users\mt7da\AppData\Local\Programs\Python\Python39\lib\site-packages\speech_recognition\__init__.py", line 113, in get_pyaudio
    raise AttributeError("PyAudio 0.2.11 or later is required (found version {})".format(pyaudio.__version__))
AttributeError: PyAudio 0.2.11 or later is required (found version 0.2.8)

My code:

import speech_recognition as sr

r = sr.Recognizer()

def record():
    with sr.Microphone() as source:
        audio = r.listen(source)
        voice = ""
        try:
            voice = r.recognize_google(audio, language="tr-TR")
        except sr.UnknownValueError:
            print("I don't understand")
        except sr.RequestError:
            print("There is an error on the system")
        return voice

print("How can I help you?")
voice = record()
print(voice)

Traceback:

Traceback (most recent call last):
  File "C:\Users\mt7da\PycharmProjects\pythonProject\venv\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
    import pyaudio
ModuleNotFoundError: No module named 'pyaudio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mt7da\PycharmProjects\pythonProject\Alexa.py", line 18, in <module>
    voice = record()
  File "C:\Users\mt7da\PycharmProjects\pythonProject\Alexa.py", line 6, in record
    with sr.Microphone() as source:
  File "C:\Users\mt7da\PycharmProjects\pythonProject\venv\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
    self.pyaudio_module = self.get_pyaudio()
  File "C:\Users\mt7da\PycharmProjects\pythonProject\venv\lib\site-packages\speech_recognition\__init__.py", line 110, in get_pyaudio
    raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
How can I help you?

Process finished with exit code 1

All helps will appreciated!

ResulVlnzr
  • 31
  • 5
  • 1
    Maybe this https://stackoverflow.com/questions/52283840/i-cant-install-pyaudio-on-windows-how-to-solve-error-microsoft-visual-c-14 will help you? – MaciejB Nov 11 '20 at 09:40
  • I installed PyAudio on cmd and it succesfully installed but i need to install PyAudio on PyCharm not on cmd i already installed it on cmd but i don't know if i really need to install Microsoft Visual C++ but if you have something for me to install please can you give me the link? – ResulVlnzr Nov 11 '20 at 09:46
  • I installed PyAudio from this link https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio – ResulVlnzr Nov 11 '20 at 09:48
  • If you want to install it in PyCharm go to File > Settings > Project Interpreter (in Project: Name_of_Project) > Install (Alt + Insert) > write PyAudio in search box > Install – MaciejB Nov 11 '20 at 10:08
  • I know how to install but i got error when i install – ResulVlnzr Nov 11 '20 at 10:19
  • Try to use in command line (PyCharm) pip install pipwin what enable you to use "pip" for Windows and then pipwin install PyAudio. It might be a solution. – MaciejB Nov 11 '20 at 10:23
  • I tried pipwin install PyAudio before but it didn't worked – ResulVlnzr Nov 11 '20 at 10:26
  • Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6. For those versions, both 32-bit and 64-bit wheels are available. It is a copy-paste message from https://people.csail.mit.edu/hubert/pyaudio/ so it might be unable to work with PyAudio on Python 3.9 – MaciejB Nov 11 '20 at 10:31
  • oh thanks so what should I do? Because ı am using python 3.9 – ResulVlnzr Nov 11 '20 at 10:37
  • You can try to use command ```py -3.6 -m pip install PyAudio```. It probably should install PyAudio with 3.6 Python version – MaciejB Nov 11 '20 at 10:38
  • I tried but it says "Requested Python version (3.6) not installed, use -0 for available pythons" – ResulVlnzr Nov 11 '20 at 10:39
  • @MaciejB I tried `py -0`and it says `-3.9-64` – ResulVlnzr Nov 11 '20 at 10:45
  • The last one idea - try to use pip install PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl or pip install PyAudio‑0.2.11‑cp39‑cp39m‑win_amd64.whl If it doesn't work I have no other ideas how to run this.. – MaciejB Nov 11 '20 at 10:52
  • 'PyAudio-0.2.11-cp39-cp39-win_amd64.whl' i installed this, is this appropriate for my computer? – ResulVlnzr Nov 11 '20 at 10:55
  • It should be automatically adjusted. If everything works - its good. There cp39-cp39 means Python 3.9 that you are using. – MaciejB Nov 11 '20 at 10:56
  • Yes I am using python 3.9 but can you solve my PyCharm problem wait I will post screenshot – ResulVlnzr Nov 11 '20 at 10:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224412/discussion-between-resulvlnzr-and-maciejb). – ResulVlnzr Nov 11 '20 at 10:58
  • I need to go right now by for now! – ResulVlnzr Nov 11 '20 at 11:01

0 Answers0