简体   繁体   English

如何修复 PyAudio、PortAudio 的安装问题:“致命错误 C1083:无法打开包含文件:'portaudio.h':没有这样的文件或目录”

[英]How to fix installation issues for PyAudio, PortAudio: "fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory"

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.所以在查看了那个错误之后,我读到我需要安装 portaudio。 So I did python -m pip install portaudio and got this error:所以我做了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.我现在不知道 go 从这里到哪里。

Try This, CMD as Administrator and run the following:试试这个,以管理员身份 CMD 并运行以下命令:

pip install pipwin
pipwin install pyaudio

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 PortAudio for 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 Tutorial for compiling it yourself. AFAIK,在 Windows 上获取它的官方方法是下载源代码,然后按照教程中的说明自行编译。 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.您可能希望使用用于 Python C 扩展的相同编译器来构建它,尽管我不确定这是否需要。

Or, if you're using a third-party package manager like Chocolatey on 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.最后,似乎有很多人为 Windows 提供了非官方的预编译 PortAudio 二进制文件。 If you search for "portaudio windows binary" or "portaudio windows pre-compiled" you'll find a number of them.如果您搜索“portaudio windows binary”或“portaudio windows pre-compiled”,您会发现其中的一些。 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.如果您使用的是 Anaconda/Miniconda,您应该首先使用conda install pyaudio而不是pip install pyaudio You should really only use pip for packages that aren't available on conda or conda-forge .你真的应该只将pip用于condaconda-forge 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的依赖项,或者告诉您为什么不能。

The official PyAudio 0.2.11 does not support Python 3.7+, and trying to install results in the error C1083: Cannot open include file: 'portaudio.h' .官方 PyAudio 0.2.11 不支持 Python 3.7+,尝试安装会报错C1083: Cannot open include file: 'portaudio.h'

However, there are unofficial wheels for PyAudio that support 3.7+.但是,PyAudio 有支持 3.7+ 的非官方轮子

If you are using the official version, you must use Python 3.6 with PyAudio 0.2.11.如果您使用的是正式版,则必须使用 Python 3.6 和 PyAudio 0.2.11。

See http://people.csail.mit.edu/hubert/pyaudio/http://people.csail.mit.edu/hubert/pyaudio/

If you get an error when trying to use pipwin to install this, you have to run it through python as windows doesn't recognize pipwin(at least for me)如果您在尝试使用 pipwin 安装时遇到错误,则必须通过 python 运行它,因为 windows 无法识别 pipwin(至少对我而言)

pip install pipwin
python -m pipwin install pyaudio

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 install pyaudio

works perfect on 3.6.x or earlier.在 3.6.x 或更早版本上完美运行。

You can install Anaconda install pyaudio using it.您可以使用它安装 Anaconda install pyaudio。 You must add Anaconda to path.您必须将 Anaconda 添加到路径。 After installing Anaconda and adding to path then in your command prompt[cmd] type conda install pyaudio.安装 Anaconda 并添加到路径后,在命令提示符 [cmd] 中键入 conda install pyaudio。 And whala还有鲸鱼

On Ubuntu distributions you can first run在 Ubuntu 发行版上,您可以先运行

sudo apt install portaudio19-dev

and then reinstall pyaudio with pip again.然后再次使用 pip 重新安装 pyaudio。

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康达更新--全部

Use the Following Commands使用以下命令

pip install pipwin
pipwin refresh
pipwin install pyaudio

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.让我知道它是否有效。

暂无
暂无

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

相关问题 安装 pygrahviz 的问题“致命错误 C1083:无法打开包含文件:‘graphviz/cgraph.h’:没有此类文件或目录” - Issues installing pygrahviz "fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory" portaudio.h:没有这样的文件或目录 - portaudio.h: No such file or directory 致命错误C1083:无法打开包含文件:'openssl / opensslv.h':没有这样的文件或目录 - fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory 致命错误 C1083:无法打开包含文件:'dlfcn.h':没有这样的文件或目录 PyLPSolve - fatal error C1083: Cannot open include file: 'dlfcn.h': No such file or directory PyLPSolve 致命错误 C1083:无法打开包含文件:“mecab.h”:没有这样的文件或目录 - fatal error C1083: Cannot open include file: 'mecab.h': No such file or directory 致命错误 C1083:无法打开包含文件:'io.h':没有这样的文件或目录 - fatal error C1083: Cannot open include file: 'io.h': No such file or directory 安装 PyAudio 给出错误“portaudio.h”文件未找到 - Installing PyAudio gives error "portaudio.h" file not found PyAudio 无法安装:“致命错误:找不到‘portaudio.h’文件” - PyAudio won't install: "fatal error: 'portaudio.h' file not found" snappy/snappymodule.cc(31): 致命错误 C1083: 无法打开包含文件: 'snappy-c.h': 没有那个文件或目录 - snappy/snappymodule.cc(31): fatal error C1083: Cannot open include file: 'snappy-c.h': No such file or directory MySQLdb/_mysql.c(29): 致命错误 C1083: 无法打开包含文件: 'mysql.h': 没有这样的文件或目录 - MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM