在mac中找不到pyaudio检查安装 [英] Could not find pyaudio check installation in mac

查看:161
本文介绍了在mac中找不到pyaudio检查安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 brew 安装了 portaudio,并在我的 macos 中使用了 pip3 安装了语音识别和 pyaudio.运行以下代码时出现错误

I have installed portaudio using brew and installed speechRecognition, pyaudio using pip3 in my macos. I am getting error while running following 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

错误:

     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

我正在使用 python-shell 在我的 nodejs 应用程序中运行这个 python 脚本.当我只使用 python3 test.py 运行这个脚本时,它可以工作,但是使用 python test.py,它不工作.在我的节点应用程序中,它也不起作用.我认为 node 正在基本的 python 2.7 版上执行这个脚本.我使用的是 MacOs sierra 操作系统.

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:-)

推荐答案

看来您已经为 python3 安装了软件包,这就是它使用它的原因,但是在从 python2.7 运行脚本时,它给出了错误,解决它你必须为python2.7版本安装相同的包.

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 安装pyaudio

这篇关于在mac中找不到pyaudio检查安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆