尝试使用PyAudio
安装pip
软件包时显示错误,而其他软件包则正常安装。
我正在使用python 3.7。为什么会发生此错误?
C:\Users\Himanshu>pip install PyAudio
Collecting PyAudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: PyAudio
Running setup.py install for PyAudio ... error
Complete output from command c:\users\himanshu\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Himanshu\\AppData\\Local\\Temp\\pip-install-romfztqt\\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\Himanshu\AppData\Local\Temp\pip-record-bmeri0ux\install-record.txt --single-version-externally-managed --compile:
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
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:\users\himanshu\appdata\local\programs\python\python37\include -Ic:\users\himanshu\appdata\local\programs\python\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.7\Release\src/_portaudiomodule.obj
_portaudiomodule.c
c:\users\himanshu\appdata\local\programs\python\python37\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\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\users\himanshu\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Himanshu\\AppData\\Local\\Temp\\pip-install-romfztqt\\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\Himanshu\AppData\Local\Temp\pip-record-bmeri0ux\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Himanshu\AppData\Local\Temp\pip-install-romfztqt\PyAudio\
答案 0 :(得分:1)
pip install pipwin
pipwin install pyaudio
答案 1 :(得分:0)
我分析了问题,并且在python 3.7上遇到了相同的错误,但是在python 3.6上却没有出现错误。 我对此进行了调查,发现PyAudio仅支持3.6版本。 您可以在http://people.csail.mit.edu/hubert/pyaudio/处找到该信息。 一种解决方法是将pyaudio的源代码https://github.com/jleb/pyaudio放入Lib文件夹中。或者,您当然可以安装受支持的版本之一。我猜想这是python版本的问题。
答案 2 :(得分:0)
在我的Linux Mint 20.04上
我的2行代码确实安装到了Python 3.8
result.extend(new_data)
但是,PyAudio实际上并没有为我工作。
似乎,Python 3.7及更高版本不再支持Pyaudio