简体   繁体   English

为什么在尝试安装pyaudio时出现错误?

[英]Why I get error when I try to install pyaudio?

The first error whas Microsoft Visual C++ 14.0 is not installed and I fixed it... Now when I try to install pyaudio I get another error. 没有安装Microsoft Visual C ++ 14.0时出现的第一个错误,我已将其修复。。。现在尝试安装pyaudio时出现另一个错误。 (I've Windows 10) (我有Windows 10)

I've installed all visual studio's packages... I tried also to use wheel installation but it says that wheel is not supported on this platform 我已经安装了所有Visual Studio的软件包...我也尝试过使用滚轮安装,但是它说此平台不支持滚轮

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\Hp\PycharmProjects\Jarvis\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Hp\\AppData\\Local\\Temp\\pip-install-r8s
c6ih0\\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\Hp\AppDa
ta\Local\Temp\pip-record-zm1aoh_y\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Hp\PycharmProjects\Jarvis\venv\include\site\python3.7\pyaudio:
    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\2019\BuildTools\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -IC:\Users\Hp\PycharmPro
jects\Jarvis\venv\include -IC:\Users\Hp\AppData\Local\Programs\Python\Python37\include -IC:\Users\Hp\AppData\Local\Programs\Python\Python37\include "-IC:\Program Files (x86)\Microsoft Visua
l Studio\2019\BuildTools\VC\Tools\MSVC\14.22.27905\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.22.27905\include" "-IC:\Program Files (
x86)\Windows Kits\NETFXSDK\4.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC
:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1
8362.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.7\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    C:\Users\Hp\AppData\Local\Programs\Python\Python37\include\pyconfig.h(117): warning C4005: 'MS_WIN64': ridefinizione macro
    src/_portaudiomodule.c: note: vedere la precedente definizione di 'MS_WIN64'
    src/_portaudiomodule.c(29): fatal error C1083: Non Š possibile aprire il file inclusione: 'portaudio.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.22.27905\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

From the official docs : 从官方文档

To build PyAudio from source, you will also need to build PortAudio v19 要从源代码构建PyAudio,您还需要构建PortAudio v19

That being said and seeing your error message: 'portaudio.h': No such file or directory error , I think you have not installed this dependency. 话虽如此,然后看到您的错误消息: 'portaudio.h': No such file or directory error ,我认为您尚未安装此依赖项。

The key part here is that PyAudio only provides python bindings to the Portaudio library, but does not include the library itself, unless you install using a .whl , but these are not available for python 3.7 . 此处的关键部分是PyAudio仅提供与Portaudio库的python绑定,但不包括该库本身,除非您使用.whl安装,但这些.whl不适用于python 3.7 Again, from the docs (emphasis mine): 再次,从文档(重点是我的):

pip will fetch and install PyAudio wheels (prepackaged binaries). pip将获取并安装PyAudio轮子(预包装的二进制文件)。 Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6 . 当前,有一些轮子与Python 2.7、3.4、3.5和3.6的官方发行版兼容。 For those versions, both 32-bit and 64-bit wheels are available. 对于那些版本,既有32位轮子又有64位轮子。

So your solution is to either download and install the missing library, or move to a python version for which there are pre built wheels that include Portaudio 因此,您的解决方案是下载并安装缺少的库,或者移动到python版本, Portaudio预先构建了包含Portaudio轮子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM