首先,我是python开发的新手。我看了很多教程,现在我正在努力开始。我在安装PyAudio和portaudio时遇到问题。
这是错误。
当我执行以下命令时
python -m pip install pyaudio
我收到以下错误。
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\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe'
failed with exit status 2
---------------------------------------- Command ""C:\Users\This PC\AppData\Local\Programs\Python\Python37-32\python.exe" -u -c "import
setuptools,
tokenize;__file__='C:\\Users\\THISPC~1\\AppData\\Local\\Temp\\pip-install-3ock7jqh\\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\THISPC~1\AppData\Local\Temp\pip-record-14pe9p6y\install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in
C:\Users\THISPC~1\AppData\Local\Temp\pip-install-3ock7jqh\pyaudio\
看完错误之后,我读到我需要安装portaudio。所以我做了以下命令。 python -m pip install portaudio
和我得到以下错误。
Collecting portaudio Could not find a version that satisfies the
requirement portaudio (from versions: ) No matching distribution found
for portaudio
我现在不知道从哪里开始。老实说,这让python看起来真的很烦人。任何帮助表示赞赏。
portaudio
不是Python包,它是一个完全独立于Python的C库,所以你不能通过pip
安装它。
有关获取它并在您的平台上安装它的官方方式的详细信息,请参阅PortAudio网站。
AFAIK,在Windows上获取它的官方方法是下载源代码,然后按照Tutorial中的说明自行编译。你可能想用你用于Python C扩展的相同编译器构建它,虽然我不确定是否需要它。
或者,如果您在Windows上使用Chocolatey等第三方软件包管理器,则很有可能安装PortAudio。
或者,如果您使用Anaconda或Miniconda作为Python,conda
包管理器知道如何安装Python包依赖的非Python包,including portaudio
。
最后,似乎有很多人为Windows提供非官方的预编译PortAudio二进制文件。如果您搜索“portaudio windows binary”或“portaudio windows pre-compiled”,您会找到其中的一些。我不知道有多少经过充分测试,最新等等。
如果你正在使用Anaconda / Miniconda,你应该首先使用conda install pyaudio
而不是pip install pyaudio
。你应该只使用pip
用于conda
或conda-forge
上没有的包。
如果你还没有设置conda-forge
,你可能想先做:
conda config --add channels conda-forge
然后,这应该是你所需要的:
conda install pyaudio
与pip
软件包不同,portaudio
软件包只是假设您正确安装了conda
,portaudio
软件包将自动安装pyaudio
作为C1083: Cannot open include file: 'portaudio.h'
的依赖项,或告诉您为什么它不能。
Python 3.7不支持PyAudio 0.2.11,并尝试在错误http://people.csail.mit.edu/hubert/pyaudio/中安装结果。
您必须将Python 3.6与PyAudio 0.2.11一起使用。
见qazxswpoi