You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 18LTS下PyAudio安装失败求助

Hey, let's fix that PyAudio installation issue you're having on Ubuntu 18.04 LTS!

Looking at your error log, the critical line that tells us what's wrong is:

src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or directory

The problem here is that libportaudio2 (which you installed) is just the runtime library for PortAudio—it doesn't include the header files and development resources needed to compile PyAudio from source. You need the dedicated development package instead.

Here's how to fix it step by step:

  1. Install the PortAudio development package
    Run this command to get portaudio19-dev, which includes the missing portaudio.h and everything else required for compiling PyAudio:

    sudo apt-get update && sudo apt-get install portaudio19-dev
    
  2. Reinstall PyAudio properly
    Now that the development files are in place, re-run the install command. And since you saw those cache permission warnings, using -H with sudo ensures the home directory context is set correctly to avoid those issues:

    sudo -H python -m pip install pyaudio
    

Quick extra tips:

  • If you need PyAudio for Python 3 instead of Python 2, just swap out python for python3 in the install command:
    sudo -H python3 -m pip install pyaudio
    
  • You already have libasound-dev installed, which is the ALSA audio system library PyAudio relies on—no need to modify that installation.

内容的提问来源于stack exchange,提问作者echo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:04:21