【问题标题】:How to properly install PyAudio for the latest version of Python?如何为最新版本的 Python 正确安装 PyAudio?
【发布时间】:2021-04-11 21:00:10
【问题描述】:

我在最新版本的 Python (3.9) 中使用 speech_recognition。而且由于某种原因,pip 没有(仍然没有)允许我安装pyaudio

错误信息示例:

_portaudiomodule.c
    c:\program files\python39\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
    src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
    src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
    ----------------------------------------

寻找portaudio.h 做了什么对我来说毫无意义。 这是解决方案。希望你不要像我一样浪费时间。

【问题讨论】:

    标签: python speech-recognition pyaudio google-speech-api


    【解决方案1】:

    原因是pipPyPi 获取包。而且 PyPi 没有支持 Python 3.9 的 PyAudio 包。这就是为什么尝试安装pyaudiopip install pyaudio 是没有用的。 相反,您应该做的是转到 Unofficial Windows Binaries for Python Extension Packages 页面并下载 pip 轮:

    最后一步是运行

    pip install [insert pyaudio wheel directory]\pyAudio-0.2.11-cp39-cp39-win_amd64.whl

    你应该没问题的。

    顺便说一句,这个技巧适用于您想使用最新的python 版本运行的其他包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 2017-08-05
      • 2017-11-27
      • 2020-06-12
      • 1970-01-01
      相关资源
      最近更新 更多