Python包安装问题:PyAudio、PortAudio
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51992375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python package installation issues: PyAudio, PortAudio
提问by KevinM1990112qwq
I am having issues installing PyAudio and portaudio.
我在安装 PyAudio 和 portaudio 时遇到问题。
When I do python -m pip install pyaudio
I get this error:
当我这样做时,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\
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:
因此,在查找该错误后,我读到我需要安装 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
I have no idea where to go from here now.
我现在不知道该往哪里去。
采纳答案by abarnert
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
.
portaudio
不是 Python 包,它是一个完全独立于 Python 的 C 库,因此您无法通过pip
.
See the PortAudiofor website for details on the official way to get it and install it on your platform.
有关获取它并在您的平台上安装它的官方方法的详细信息,请参阅PortAudio的网站。
AFAIK, the official way to get it on Windows is to download the source and then follow the instructions in the Tutorialfor 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.
AFAIK,在 Windows 上获取它的官方方法是下载源代码,然后按照教程中的说明自行编译。您可能希望使用用于 Python C 扩展的相同编译器来构建它,尽管我不确定是否需要这样做。
Or, if you're using a third-party package manager like Chocolateyon Windows, there's a good chance it can install PortAudio.
或者,如果您在 Windows 上使用像Chocolatey这样的第三方包管理器,它很有可能安装 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
.
或者,如果您为 Python 使用 Anaconda 或 Miniconda,conda
包管理器知道如何安装 Python 包所依赖的非 Python 包,包括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.
最后,似乎有很多人为 Windows 提供了非官方的预编译 PortAudio 二进制文件。如果您搜索“portaudio windows binary”或“portaudio windows pre-compiled”,您会找到其中的一些。我不知道这些是如何经过充分测试的、最新的等等。
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
.
如果您使用的是 Anaconda/Miniconda,您应该使用conda install pyaudio
而不是pip install pyaudio
一开始。你真的应该只pip
用于在conda
或上不可用的包conda-forge
。
If you haven't set up conda-forge
yet, you probably want to do that first:
如果你还没有设置conda-forge
,你可能想先做:
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.
与pip
仅假设您已portaudio
正确安装的软件包不同,该conda
软件包将portaudio
作为 的依赖项自动安装pyaudio
,或者告诉您为什么不能安装。
回答by hassanzadeh.sd
Try This, CMD as Administrator and run the following:
试试这个,以管理员身份 CMD 并运行以下命令:
pip install pipwin
pipwin install pyaudio
回答by cowlinator
PyAudio 0.2.11 is not supported for Python 3.7, and trying to install results in the error C1083: Cannot open include file: 'portaudio.h'
.
Python 3.7 不支持 PyAudio 0.2.11,尝试安装会导致错误C1083: Cannot open include file: 'portaudio.h'
.
You must use Python 3.6 with PyAudio 0.2.11.
您必须使用 Python 3.6 和 PyAudio 0.2.11。
回答by Josué Cano
I installed pyaudio on python 3.6.x without problem, but is not working on later versions.
我在 python 3.6.x 上安装了 pyaudio 没有问题,但在更高版本上不起作用。
py -m pip instal pyaudio
works perfect on 3.6.x or earlier.
在 3.6.x 或更早版本上完美运行。
回答by AYIBO ROBERTS
You can install Anaconda install pyaudio using it. You must add Anaconda to path. After installing Anaconda and adding to path then in your command prompt[cmd] type conda install pyaudio. And whala
您可以使用它安装 Anaconda install pyaudio。您必须将 Anaconda 添加到路径。安装 Anaconda 并添加到路径后,然后在命令提示符 [cmd] 中键入 conda install pyaudio。还有哇啦
回答by Sarthak Chauhan
You can install Portaudio
with
您可以安装Portaudio
使用
pip install port audio
you may also need to
你可能还需要
pip install ConfigParser
Let me know if it's work.
让我知道它是否有效。
回答by Mani Agarwal
If you are using anaconda then this problem is because your versions are not upgraded.To upgrade all the packages simply run the following command in the terminal.
如果您使用的是 anaconda,那么这个问题是因为您的版本没有升级。要升级所有软件包,只需在终端中运行以下命令。
conda update --all
康达更新 --all