Could not find pyaudio check installation in mac

旧街凉风 提交于 2019-12-12 04:39:12

问题


I have installed portaudio using brew and installed speechRecognition, pyaudio using pip3 in my macos. I am getting error while running following code

CODE:

    #!/usr/bin/env python
    # Python 3
    import os
    import sys
    import speech_recognition as sr
    r = sr.Recognizer()

    with sr.Microphone() as source:
        print ("say something!");
        audio = r.listen(source)

     try:
          print("google thinks you said" +r.recognize_google(audio))

     except:
          pass

ERROR:

     Traceback (most recent call last):
     File "test.py", line 8, in <module>
     with sr.Microphone() as source:
     File "/Library/Python/2.7/site-
     packages/speech_recognition/__init__.py", line 79, in __init__
      self.pyaudio_module = self.get_pyaudio()
     File "/Library/Python/2.7/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

I am using python-shell for running this python script in my nodejs application. when I run only this script with the python3 test.py, it's working but with python test.py, it is not working. in my node application also it is not working. I think node is executing this script on basic python version 2.7. I am using MacOs sierra operating system.

Please help me thanks in advance:-)


回答1:


It seems you've installed packages for python3 and that's the reason it is working with it but while running script from python2.7 it is giving out error, to resolve it you have to install same packages for python2.7 version.

Can you run command following command and check if it works.

pip2.7 install pyaudio




回答2:


Install 2 things,

brew install portaudio19-dev python-pyaudio

and then,

pip install pyaudio


来源:https://stackoverflow.com/questions/47121382/could-not-find-pyaudio-check-installation-in-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!