gpt4 book ai didi

python - 安装时 PyAudio 错误(子进程退出并出现错误)

转载 作者:行者123 更新时间:2023-12-03 08:10:08 24 4
gpt4 key购买 nike

Building wheel for pyaudio (setup.py) ... error
error: subprocess-exited-with-error

安装时显示此错误,我已经更新了 pip 和 Python 版本,但仍然遇到相同的错误。完整错误:

(stt) F:\Python>pip install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz (37 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
building '_portaudio' extension
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\Jug\AppData\Local\Temp\pip-install-7dl19imj\pyaudio_618223816ae04aecb9311a803aa75afe\setup.py", line 106, in <module>
setup(name='PyAudio',
File "F:\Python\stt\lib\site-packages\setuptools\__init__.py", line 155, in setup
return distutils.core.setup(**attrs)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
return run_commands(dist)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
dist.run_commands()
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "F:\Python\stt\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
self.run_command('build')
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "F:\Python\stt\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
_build_ext.run(self)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 339, in run
self.build_extensions()
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "F:\Python\stt\lib\site-packages\setuptools\command\build_ext.py", line 202, in build_extension
_build_ext.build_extension(self, ext)
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 528, in build_extension
objects = self.compiler.compile(sources,
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 327, in compile
self.initialize()
File "F:\Python\stt\lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 224, in initialize
vc_env = _get_vc_env(plat_spec)
File "F:\Python\stt\lib\site-packages\setuptools\msvc.py", line 316, in msvc14_get_vc_env
return _msvc14_get_vc_env(plat_spec)
File "F:\Python\stt\lib\site-packages\setuptools\msvc.py", line 270, in _msvc14_get_vc_env
raise distutils.errors.DistutilsPlatformError(
setuptools._distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
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: subprocess-exited-with-error

× Running setup.py install for pyaudio did not run successfully.
│ exit code: 1
╰─> [8 lines of output]
running install
F:\Python\stt\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyaudio

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

最佳答案

https://www.lfd.uci.edu/~gohlke/pythonlibs/ 获取合适的 .whl 文件在pyaudio下。您可以通过在 cmd 或终端中键入 python 来找到适当的 .whl 文件。你会得到这样的东西:

Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

图片描述:

enter image description here

注意 python 版本以及 python 是 64 位还是 32 位。然后获取适合该版本和计算机的 .whl 文件。对我来说,这将是这个 .whl 文件:

PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl

接下来,转到下载的位置。例如,C:\Users\user\Downloads>,然后使用 pip 安装 .whl 文件。以我为例:

pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl

or if the above doesn't work try:

由于 pyAudio 有 portAudio 作为依赖项,因此您首先必须安装 portaudio。

brew 安装 portaudio

然后尝试:pip3 install pyAudio。如果安装 portAudio 后问题仍然存在,您可以指定编译器能够找到源程序的目录路径(例如:portaudio.h)。由于 header 应该位于/usr/local/include 目录中:

pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

关于python - 安装时 PyAudio 错误(子进程退出并出现错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71072094/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com