尝试使用 pip 安装某些依赖项时如何修复错误

How to fix error while trying to install some dependencies using pip

我刚开始使用 Mozilla 的 Deep Speech 并尝试安装 mic_vad_streaming 示例的依赖项,但我 运行 遇到了这个错误。我正在按照我用于参考的以下视频中的步骤操作 - https://www.youtube.com/watch?v=c_0Q3T0XYTA&t=211s .

ERROR: Command errored out with exit status 1:
     command: 'c:\users\admin\deepspeech\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Admin\AppData\Local\Temp\pip-install-rvw2t7px\pyaudio\setup.py'"'"'; __file__='"'"'C:\Users\Admin\AppData\Local\Temp\pip-install-rvw2t7px\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\Admin\AppData\Local\Temp\pip-record-422heum9\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\admin\deepspeech\include\site\python3.8\pyaudio'
         cwd: C:\Users\Admin\AppData\Local\Temp\pip-install-rvw2t7px\pyaudio\
    Complete output (17 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    copying src\pyaudio.py -> build\lib.win-amd64-3.8
    running build_ext
    building '_portaudio' extension
    creating build\temp.win-amd64-3.8
    creating build\temp.win-amd64-3.8\Release
    creating build\temp.win-amd64-3.8\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.26.28801\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:\users\admin\deepspeech\include -IC:\Python38\include -IC:\Python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.26.28801\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.26.28801\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.8\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.8\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    C:\Python38\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\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\admin\deepspeech\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Admin\AppData\Local\Temp\pip-install-rvw2t7px\pyaudio\setup.py'"'"'; __file__='"'"'C:\Users\Admin\AppData\Local\Temp\pip-install-rvw2t7px\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\Admin\AppData\Local\Temp\pip-record-422heum9\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\admin\deepspeech\include\site\python3.8\pyaudio' Check the logs for full command output. 

使用pipwin安装pyaudio即可解决

pip install pipwin

然后

pipwin install pyaudio