python 计数找到 pyaudio

python count find pyaudio

这是我尝试使用 python 的 pip 安装 pyaudio 时生成的异常:

ERROR: Complete output from command 'd:\python\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\ds528\AppData\Local\Temp\pip-install-3g3d86u3\pyaudio\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ds528\AppData\Local\Temp\pip-record-u7rijpbk\install-record.txt' --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying src\pyaudio.py -> build\lib.win32-3.7
    running build_ext
    building '_portaudio' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\python\include -Id:\python\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.20.27508\include" "-IC:\Program Files (x86)\Windows Kits\include.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.17763.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.7\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    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\2019\BuildTools\VC\Tools\MSVC\14.20.27508\bin\HostX86\x86\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command "'d:\python\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\ds528\AppData\Local\Temp\pip-install-3g3d86u3\pyaudio\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ds528\AppData\Local\Temp\pip-record-u7rijpbk\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ds528\AppData\Local\Temp\pip-install-3g3d86u3\pyaudio\

您正在尝试从源代码和 Windows 平台上编译 pyaudio,这通常比人们想象的要困难。

您遇到的具体问题是编译器正在尝试查找您没有的包含文件 portaudio.h,因为它不是标准的 Windows 包含文件,而且显然也没有在下载包中。

很明显 pip 尝试编译而不是进行二进制安装的原因是最近的二进制安装是针对 Python 3.6 的,并且您有 Python 3.7。

我建议您将 Python 3.6 与现有的 Python 3.7 一起安装,以便您可以开始使用此模块。在适当的时候可能会有 Python 3.7 绑定可用,但也可能不会。此项目的 PyPI 页面已超过 2 年未更新。