繁体   English   中英

无法在 python 3.7 中安装和使用 pyaudio

[英]can't install and use pyaudio in python 3.7

C:\Users\Dell\PycharmProjects\pythonProject1>pip install pyaudio
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
Using legacy 'setup.py install' for pyaudio, since package 'wheel' is not installed.
Installing collected packages: pyaudio
    Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Dell\\AppData\\Local\\Temp\\pip-install-qm5dhs1u\\pyaud
io_0fa5615a0f1d45fe897d47e2b712cf51\\setup.py'"'"'; __file__='"'"'C:\\Users\\Dell\\AppData\\Local\\Temp\\pip-install-qm5dhs1u\\pyaudio_0fa5615a0f1d45fe897d47e2b712cf
51\\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\Dell\AppData\Local\Temp\pip-record-mst52wx_\install-record.txt' --single-version-externally-managed --compile --install-head
ers 'c:\python37\Include\pyaudio'
         cwd: C:\Users\Dell\AppData\Local\Temp\pip-install-qm5dhs1u\pyaudio_0fa5615a0f1d45fe897d47e2b712cf51\
    Complete output (9 lines):
    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
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Dell\\AppData\\Local\\
Temp\\pip-install-qm5dhs1u\\pyaudio_0fa5615a0f1d45fe897d47e2b712cf51\\setup.py'"'"'; __file__='"'"'C:\\Users\\Dell\\AppData\\Local\\Temp\\pip-install-qm5dhs1u\\pyaud
io_0fa5615a0f1d45fe897d47e2b712cf51\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python37\python.exe' -u -c 'im
port sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Dell\\AppData\\Loca
l\\Temp\\pip-install-qm5dhs1u\\pyaudio_0fa5615a0f1d45fe897d47e2b712cf51\\setup.py
'"'"'; __file__='"'"'C:\\Users\\Dell\\AppData\\Local\\Temp\\pip-install-qm5dhs1u\
\pyaudio_0fa5615a0f1d45fe897d47e2b712cf51\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.cl
ose();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Dell\AppData\Local\Temp\pip-record-mst52wx_\install-record.txt' --single-version-exte
rnally-managed --compile --install-headers 'c:\python37\Include\pyaudio' Check the logs for full command output.

如错误消息所述,请安装构建工具:

Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

您需要按照以下两个步骤安装 pyaudio:-

pip install pipwin
pipwin install pyaudio

我希望这可以解决您的问题。

我制作了一个程序来为你解决这个问题。 我会把代码放在这里。 它使用os.system为您做 CMD 的东西,只是一种更简单的下载方式。

import os
os.system('cmd /k "pip install pipwin"')
os.system('cmd /k "pipwin install PyAudio"')

然后运行它,它会为你做这一切,如果它在第一次尝试时不起作用,请再次运行它。 有时它必须重新启动 CMD 才能使pipwin开始工作

暂无
暂无

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

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