本文主要是介绍src/pyaudio/device_api.c:9:10: fatal error: portaudio.h: 没有那个文件或目录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
(venv) shgbitai@shgbitai-C9X299-PGF:~/pythonworkspace/ai-accompany$ pip install pyaudio sounddevice
Collecting pyaudioDownloading PyAudio-0.2.14.tar.gz (47 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.1/47.1 kB 644.0 kB/s eta 0:00:00Installing build dependencies ... doneGetting requirements to build wheel ... donePreparing metadata (pyproject.toml) ... done
Collecting sounddeviceDownloading sounddevice-0.5.0-py3-none-any.whl.metadata (1.4 kB)
Collecting CFFI>=1.0 (from sounddevice)Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB)
Collecting pycparser (from CFFI>=1.0->sounddevice)Downloading pycparser-2.22-py3-none-any.whl.metadata (943 bytes)
Downloading sounddevice-0.5.0-py3-none-any.whl (32 kB)
Downloading cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 479.4/479.4 kB 3.5 MB/s eta 0:00:00
Downloading pycparser-2.22-py3-none-any.whl (117 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.6/117.6 kB 13.5 MB/s eta 0:00:00
Building wheels for collected packages: pyaudioBuilding wheel for pyaudio (pyproject.toml) ... errorerror: subprocess-exited-with-error× Building wheel for pyaudio (pyproject.toml) did not run successfully.│ exit code: 1╰─> [18 lines of output]running bdist_wheelrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-cpython-312creating build/lib.linux-x86_64-cpython-312/pyaudiocopying src/pyaudio/__init__.py -> build/lib.linux-x86_64-cpython-312/pyaudiorunning build_extbuilding 'pyaudio._portaudio' extensioncreating build/temp.linux-x86_64-cpython-312creating build/temp.linux-x86_64-cpython-312/srccreating build/temp.linux-x86_64-cpython-312/src/pyaudiox86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -I/usr/local/include -I/usr/include -I/home/shgbitai/pythonworkspace/ai-accompany/venv/include -I/usr/include/python3.12 -c src/pyaudio/device_api.c -o build/temp.linux-x86_64-cpython-312/src/pyaudio/device_api.osrc/pyaudio/device_api.c:9:10: fatal error: portaudio.h: 没有那个文件或目录9 | #include "portaudio.h"| ^~~~~~~~~~~~~compilation terminated.error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
错误信息显示,pyaudio
依赖的 portaudio.h
文件无法找到,这是因为 PyAudio
需要依赖 PortAudio
库,而你的系统中没有安装该库。
你可以通过以下步骤解决这个问题:
1. 安装 PortAudio
库
在大多数基于 Debian 的系统(如 Ubuntu)上,可以通过包管理器 apt
安装 PortAudio
依赖。
运行以下命令:
sudo apt-get install portaudio19-dev
该命令会安装开发版本的 PortAudio,包含头文件 portaudio.h
,这是 PyAudio 构建时所需要的。
2. 重新安装 PyAudio
和 sounddevice
安装完 PortAudio
库后,重新运行安装命令:
pip install pyaudio sounddevice
如果你使用的是其他 Linux 发行版
如果你不是使用 Ubuntu 或 Debian 系列的 Linux 发行版,安装 portaudio
库的命令可能不同。你可以根据你的发行版查找相应的安装命令,例如:
-
Fedora:
sudo dnf install portaudio-devel
-
Arch Linux:
sudo pacman -S portaudio
3. 如果你仍然遇到问题
如果问题依然存在,可以考虑使用 PyAudio
的预编译二进制版本,通过 pip
安装预编译的包:
pip install pipwin
pipwin install pyaudio
总结
这个错误是由于缺少 portaudio
开发库导致的,通过安装 portaudio19-dev
库来解决此问题,然后重新安装 pyaudio
。
这篇关于src/pyaudio/device_api.c:9:10: fatal error: portaudio.h: 没有那个文件或目录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!