在命令提示符下使用以下命令安装pyaudio时:
python -m pip install pyaudio
我得到一个错误:
ERROR: Complete output from command 'C:\python\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-c823_6j8\\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-vkr4rksd\install-record.txt' --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying src\pyaudio.py -> build\lib.win-amd64-3.7
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command "'C:\python\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\admin\\AppData\\Local\\Temp\\pip-install-c823_6j8\\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-vkr4rksd\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\admin\AppData\Local\Temp\pip-install-c823_6j8\pyaudio\
答案 0 :(得分:0)
您可以简单地从here获取适合您当前Python版本的Wheel工具包
然后使用pip install <PyAudio‑0.2.11-...>.whl
安装它。 (请记住使用完整的文件名(例如pip install PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl
)。
答案 1 :(得分:-1)
您不需要下载或任何Microsoft Visual C ++构建工具。只需执行以下操作,这将是一个最终解决方案: 转到此链接后:https://www.lfd.uci.edu/~gohlke/pythonlibs/选择并下载适用于您的Python版本的PyAudio。
我下载了:
PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
将下载的文件放入Scrips文件夹。我的文件夹结构是:
`C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts`
然后,您需要使用以下命令来安装下载的脚本:
python -m pip install "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts\PyAudio-0.2.11-cp37-cp37m-win_amd64.whl"