Python软件包安装问题:PyAudio,PortAudio [英] Python package installation issues: PyAudio, PortAudio

查看:550
本文介绍了Python软件包安装问题:PyAudio,PortAudio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装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
 

我不知道现在该从哪里去.

解决方案

portaudio不是Python软件包,它是一个完全独立于Python的C库,因此您无法通过pip安装它.

有关获取并安装在平台上的官方方法的详细信息,请参见 PortAudio 网站.

>

AFAIK,在Windows上获取它的官方方法是下载源代码,然后按照教程自己进行编译.您可能想使用与Python C扩展使用的编译器相同的编译器进行构建,尽管我不确定是否需要这样做.

或者,如果您在Windows上使用巧克力之类的第三方软件包管理器,则很有可能可以安装PortAudio.

或者,如果您将Anaconda或Miniconda用于Python,则conda软件包管理器会知道如何安装Python软件包所依赖的非Python软件包,


如果您正在使用Anaconda/Miniconda,则应该首先使用conda install pyaudio而不是pip install pyaudio.对于在condaconda-forge上不可用的软件包,您实际上应该只使用pip.

如果尚未设置conda-forge,则可能要先执行以下操作:

conda config --add channels conda-forge 

然后,这应该是您所需要的:

conda install pyaudio

pip软件包(仅假定已正确安装portaudio)不同,conda软件包将自动安装portaudio作为pyaudio的依赖项,或者告诉您为什么不能这样做.

I am having issues installing PyAudio and portaudio.

When I do python -m pip install pyaudio I get this error:

    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\

So after looking that error up, I read I need to install portaudio. So I did python -m pip install portaudio and got this error:

Collecting portaudio
Could not find a version that satisfies the requirement portaudio (from versions: )
No matching distribution found for portaudio

I have no idea where to go from here now.

解决方案

portaudio is not a Python package, it's a C library that's entirely independent of Python, so you can't install it via pip.

See the PortAudio for website for details on the official way to get it and install it on your platform.

AFAIK, the official way to get it on Windows is to download the source and then follow the instructions in the Tutorial for compiling it yourself. You probably want to build it with the same compiler you use for Python C extensions, although I'm not sure if that's required.

Or, if you're using a third-party package manager like Chocolatey on Windows, there's a good chance it can install PortAudio.

Or, if you use Anaconda or Miniconda for your Python, the conda package manager knows how to install non-Python packages that Python packages depend on, including portaudio.

Finally, there seem to be a number of people providing unofficial pre-compiled PortAudio binaries for Windows. If you search for "portaudio windows binary" or "portaudio windows pre-compiled" you'll find a number of them. I have no idea how well-tested, up-to-date, etc. any of these are.


If you're using Anaconda/Miniconda, you should have used conda install pyaudio rather than pip install pyaudio in the first place. You should really only use pip for packages that aren't available on conda or conda-forge.

If you haven't set up conda-forge yet, you probably want to do that first:

conda config --add channels conda-forge 

And then, this should be all you need:

conda install pyaudio

Unlike the pip package, which just assumes you have portaudio installed properly, the conda package will either automatically install portaudio as a dependency for pyaudio, or tell you why it can't.

这篇关于Python软件包安装问题:PyAudio,PortAudio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆