pyAudio安装失败:Windows 10

时间:2018-12-20 09:49:26

标签: python pip pyaudio

当我尝试使用pyAudio安装pip install pyaudio时出现错误。看起来像这样:

C:\Users\pankajkaun>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\pankajkaun\desktop\python\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\PANKAJ~1\\AppData\\Local\\Temp\\pip-install-pw8_ueh5\\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\PANKAJ~1\AppData\Local\Temp
\pip-record-eru_9orv\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\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:\users\pankajkaun\desktop\python\include -Ic:\users\pankajkaun\desktop\python\
include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-
IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:
\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.7\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    c:\users\pankajkaun\desktop\python\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\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\users\pankajkaun\desktop\python\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\PANKAJ~1\\AppData\\Local\\Temp\\pip-install-pw8_ueh5\\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\PANKAJ~1\AppData\Local\Temp\pip-record-eru_9orv\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\PANKAJ~1\AppData\Local\Temp\pip-install-pw8_ueh5\pyaudio\

你知道这里发生了什么吗?

8 个答案:

答案 0 :(得分:2)

根据official docs of pyaudio

  

Microsoft Windows

     

使用pip安装:

     

python -m pip install pyaudio

     

注意:pip将获取并安装PyAudio滚轮(预包装的二进制文件)。当前,有一些轮子与Python 2.7, 3.4、3.5和3.6 的官方发行版兼容。对于这些版本,可以使用32位和64位Wheel。

您尝试为3.7安装pyaudio,因此尝试对其进行编译。 从Gohlke - Unofficial Windows Binaries for Python Extension Packages下载并安装wheel。可以使用32和64位python 3.7的滚轮。

答案 1 :(得分:2)

使用“ https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio ”链接根据其支持的python版本下载.whl文件。

转到以下目录并在命令提示符下运行此命令(Windows在此处) C:\ Users \ shris \ AppData \ Local \ Programs \ Python \ Python37-32 \ Scripts> pip install PyAudio-0.2.11-cp37-cp37m-win32.whl

答案 2 :(得分:2)

以admin身份运行CMD,然后运行以下两个命令即可完成工作:

1. pip安装pipwin

2. pipwin安装pyaudio

答案 3 :(得分:0)

我遇到了同样的问题,但是通过使用WHL文件解决了该问题,您可以从https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio下载该文件。

您可以下载和使用多个版本,例如PyAudio-0.2.11-cp37-cp37m-win_amd64.whl。

出于安装目的,在命令提示符下输入“ pip install“ path” \ PyAudio-0.2.11-cp37-cp37m-win_amd64.whl“。

答案 4 :(得分:0)

尝试一下:

pip install pipwin
pipwin install pyaudio

pipwin类似于pip,但是它安装了Christoph Gohlke提供的预编译的Windows二进制文件。为您节省大量的Google搜索和手动下载操作。

答案 5 :(得分:0)

似乎您需要先安装portaudio。

答案 6 :(得分:0)

这是我的计算机配置 -Windows 10 -在C:\ Program Files(x86)\ Python \ Python38-32

上安装了Python 3.8.0

我遇到了同样的问题,并通过以下步骤解决了该问题;

1 /在我的计算机上的C:\ Downloads \ PyAudio-0.2.11-cp38-cp38-win32.whl中下载https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio/PyAudio ‑ 0.2.11-cp38-cp38-win32.whl

2 /运行C:\ Program Files(x86)\ Python \ Python38-32 \ Scripts> pip3.8 install C:\ Downloads \ PyAudio-0.2.11-cp38-cp38-win32.whl --user

答案 7 :(得分:0)

首先:在窗口上使用命令=> pip install pipwin安装“ pipwin”软件包。

然后:在窗口上使用命令=> pip install pyaudio安装“ pyaudio”软件包。