1

I m working on Python 3.6.3 using conda 4.6.9 and it already has pyaudio 0.2.11 and speech recognition 3.8.1 in anaconda

but on running the code, I m still getting the error

if LooseVersion(pyaudio.__version__) < LooseVersion("0.2.11"):
AttributeError: module 'pyaudio' has no attribute '__version__'

why I m still getting this error when I m using the latest version of pyaudio.

python code:

import speech_recognition as sr 

r = sr.Recognizer()
with sr.Microphone() as source:
     print('speak say anything')
     audio = r.listen(source)
     try:
        text = r.recognize_google(audio)
        print("you said:{}".format(text))
     except:
            print("cant recognize")
Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
user11251362
  • 101
  • 2
  • 10
  • 1
    did you created file with name `pyaudio.py` ? or subfolder `pyaudio` ? Python will threads it as module and loads it instead of expected module `pyaudio` – furas Apr 04 '19 at 03:16
  • i created a file name speech.py in desktop directory. And i have conda in home directory – user11251362 Apr 04 '19 at 03:26
  • As a trouble shooting step, I'd suggest trying `import pyaudio` and checking if `pyaudio.__file__` is the location that your package got installed, rather than some other file cluttering up the module namespace by mistake. – Blckknght Apr 04 '19 at 03:42
  • i tried that , still getting the same error and i even try sudo **apt-get install python-pyaudio python3-pyaudio**, still show same error – user11251362 Apr 04 '19 at 03:57
  • As suggested @Blckknght - I would use `import pyaudio` and `print(pyaudio.__file__)` to see path to file which is imported by Python. And I would open this file in editor to see if it has `__version__` or not. It looks like this file doesn't have it. Mostly it happends when user forgot that it created file `pyaudio.py` and Python loads this file instead of expected module. Python has list `sys.path` with folders in which it looks for modules and it load first found `pyaudio.py`. You could check if you have other `pyaudio.py` on disk. Reinstalling module will not help if other file still exist. – furas Apr 04 '19 at 12:38

0 Answers0