车轮和setup.py上的PyAudio Windows 10安装错误

时间:2020-09-25 19:11:51

标签: python python-3.x pyaudio

我正在使用Python 3.8.3。

我尝试使用pip install pyaudio安装PyAudio。但是我遇到了wheel错误和一个与setup.py中的PyAudio相关的错误。

Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\17326\pycharmprojects\voice\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-
1t8lu494\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-1t8lu494\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);co
de=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\17326\AppData\Local\Temp\pip-wheel-3y_f6xu3'
       cwd: C:\Users\17326\AppData\Local\Temp\pip-install-1t8lu494\pyaudio\
  Complete output (15 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.8
  copying src\pyaudio.py -> build\lib.win32-3.8
  running build_ext
  building '_portaudio' extension
  creating build\temp.win32-3.8
  creating build\temp.win32-3.8\Release
  creating build\temp.win32-3.8\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\17326\pycharmprojects\voic
e\venv\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\Microsoft Vi
sual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" "-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.18362.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.8\Release\src/_portaudiomodule.obj
  _portaudiomodule.c
  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\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for pyaudio
  Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
    Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\17326\pycharmprojects\voice\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-instal
l-1t8lu494\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-1t8lu494\\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\17326\AppData\Local\Temp\pip-record-quacxxz7\instal
l-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\17326\pycharmprojects\voice\venv\include\site\python3.8\pyaudio'
         cwd: C:\Users\17326\AppData\Local\Temp\pip-install-1t8lu494\pyaudio\
    Complete output (15 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.8
    copying src\pyaudio.py -> build\lib.win32-3.8
    running build_ext
    building '_portaudio' extension
    creating build\temp.win32-3.8
    creating build\temp.win32-3.8\Release
    creating build\temp.win32-3.8\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\17326\pycharmprojects\vo
ice\venv\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\Microsoft
Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" "-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)\Window
s Kits\10\include\10.0.18362.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.8\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    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\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\17326\pycharmprojects\voice\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17326\
\AppData\\Local\\Temp\\pip-install-1t8lu494\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-1t8lu494\\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\17326\AppData\Loca
l\Temp\pip-record-quacxxz7\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\17326\pycharmprojects\voice\venv\include\site\python3.8\pyaudio' C
heck the logs for full command output.

然后我在Google上搜索了一下,然后发现了here。所以我安装了PyAudio-0.2.11-cp39-cp39-win_amd64.whl

键入pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl时出现错误ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

之后,我搜索了堆栈溢出。我看到有人回答说:

尝试一下:

pip install pipwin
pipwin install pyaudio

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

但是当我使用它时,出现以下错误:

Package `pyaudio` found in cache
Downloading package . . .
https://download.lfd.uci.edu/pythonlibs/w3jqiv8s/PyAudio-0.2.11-cp38-cp38-win32.whl
PyAudio-0.2.11-cp38-cp38-win32.whl
Traceback (most recent call last):
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\17326\PycharmProjects\Voice\venv\Scripts\pipwin.exe\__main__.py", line 7, in <module>
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\command.py", line 98, in main
    cache.install(package)
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\pipwin.py", line 300, in install
    wheel_file = self.download(requirement)
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\pipwin.py", line 294, in download
    return self._download(requirement, dest)
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\pipwin.py", line 290, in _download
    obj.start()
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pySmartDL\pySmartDL.py", line 267, in start
    urlObj = urllib.request.urlopen(req, timeout=self.timeout, context=self.context)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

从我看到的情况来看,pipwin使用的source已过期,因此出现此错误。

还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

您需要确定pyaudio的版本正确,例如cp38表示CPython 3.8。您还需要确保下载正确的类型,因此,如果您具有32位python,则需要具有win32的文件,对于64位,则需要win_amd64。对于您的情况,您需要PyAudio‑0.2.11‑cp38‑cp38‑win32.whl,因为它适用于32位CPython 3.8。