python-3.x - 我无法在 M1 mac 上安装 pyaudio
问题描述
我尝试在默认终端和 M1 mac 上的 Visual Studio 代码中安装 PyAudio,运行 python 3.8、macOS 11.2.1 BigSur,这是我得到的错误:
MacBook-Pro-Jakubik:~ kuba$ pip3 install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz (37 kB)
Using legacy setup.py install for pyaudio, since package 'wheel' is not installed.
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-install-yzoe7_ph/pyaudio/setup.py'"'"'; __file__='"'"'/private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-install-yzoe7_ph/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 /private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-record-jzsqhn9q/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pyaudio
cwd: /private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-install-yzoe7_ph/pyaudio/
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-3.7
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DMACOSX=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-3.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-install-yzoe7_ph/pyaudio/setup.py'"'"';__file__='"'"'/private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-install-yzoe7_ph/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 /private/var/folders/8h/c3rxt5m1367cq61wy64pl67c0000gp/T/pip-record-jzsqhn9q/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pyaudio Check the logs for full command output.
解决方案
pyaudio 需要portaudio库。使用homebrew安装它可能是最简单的(假设它已被移植到 M1 架构)。
推荐阅读
- python - 将 C++ 中的指针转换为 Cython 中的 Numpy 数组
- express - 服务器发出请求时未连接到我的数据库的正确端口
- javascript - (MongoDB Atlas + ExpressJS)如何使用路由将数据从一个 .ejs 文件发送到另一个文件,以便可以在新网页上加载数据?
- graphics - 在love2d崩溃程序中画线
- javascript - 使用 nodejs 下载损坏或无效的 HTTPS xlsx 文件
- xamarin - 为什么多边形不出现
- python - 如何自动将数字特殊方法添加到类中?
- python-3.x - 如何重新格式化数据框中的索引列?
- powershell - 使用 PowerShell 将 PC 名称和所需的更新从 WSUS 导出到 CSV
- python - tkinter - 错误地打印当前输入+以前的输入