安装 PyAudio 会出现错误“portaudio.h";文件未找到 [英] Installing PyAudio gives error "portaudio.h" file not found
问题描述
我一直在尝试为一个项目安装 PyAudio.我在 Mac 上使用 M1 芯片,操作系统 11.0.1.
I have been trying to install PyAudio for a project. I am working on a Mac with the M1 Chip, on OS 11.0.1.
每次我运行 pip3 install pyaudio
我都会遇到同样的错误:
Every time I run pip3 install pyaudio
I get the same error:
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
我已经通过 brew install portaudio
安装了 portaudio 并且有 x-code 命令行工具,但它仍然不起作用.我也试过把 sudo 放在它前面,但没有运气.
I have installed portaudio through brew install portaudio
and have x-code command line tools but it still doesn't work. I have also tried putting sudo in front of it but no luck.
感谢任何帮助!
这是错误的图像:错误
推荐答案
无法定位 PortAudio 头文件.
The PortAudio header file can't be located.
在安装 PyAudio 之前尝试运行 brew link
:
Try running brew link
before installing PyAudio:
brew install portaudio
brew link portaudio
pip3 install pyaudio
如果这不起作用,则找到该文件,sudo find/-name "portaudio.h"
,并通过 build_ext
选项提供路径作为 build_ext
选项code>pip3 install 命令.在我的例子中,返回的路径是 /usr/local/include/portaudio.h
.因此,命令如下:
If this does not work then locate the file, sudo find / -name "portaudio.h"
, and supply the path as a build_ext
option through the pip3 install
command. In my case the path returned is /usr/local/include/portaudio.h
. Hence, the command is as follows:
pip3 install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
这些可能的解决方案都在相关问题中描述:安装pyaudio时pip找不到portaudio.h 在/usr/local/include
These possible solutions are all described in the related question: when installing pyaudio, pip cannot find portaudio.h in /usr/local/include
这篇关于安装 PyAudio 会出现错误“portaudio.h";文件未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!