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

Ubuntu16.04下如何为Python3.6.5安装PyAudio模块?

Fixing PyAudio Installation for Python 3.6.5 on Ubuntu 16.04

Hey there! I get it—apt installs can be tricky when you’ve got multiple Python versions floating around. Let’s get PyAudio working with your custom Python 3.6.5 setup step by step:

Step 1: Install System Dependencies First

PyAudio relies on the PortAudio library, so we need to install its development files first (this avoids those frustrating compilation errors when using pip):

sudo apt-get update && sudo apt-get install portaudio19-dev

Step 2: Use Python 3.6’s Specific Pip to Install PyAudio

The python3-pyaudio package from apt is tied to Ubuntu 16.04’s default Python 3.5, which is why it doesn’t show up in your 3.6.5 environment. Instead, use the pip linked directly to your Python 3.6 installation:

  1. First, make sure you have pip for Python 3.6. If running which pip3.6 returns nothing, install it with:
    python3.6 -m ensurepip --upgrade
    
  2. Now install PyAudio using this version-specific pip:
    pip3.6 install pyaudio
    
    If you hit permission issues (like being blocked from writing to system directories), add the --user flag to install it only for your account:
    pip3.6 install --user pyaudio
    

Step 3: Verify the Installation

To confirm everything works, run this quick test command:

python3.6 -c "import pyaudio; print('PyAudio version:', pyaudio.__version__)"

If you see the version number printed without errors, you’re good to go!

Why This Works

Ubuntu’s apt packages are built to target the system’s default Python versions. Since you installed Python 3.6.5 manually, it’s a separate environment that doesn’t recognize packages installed via apt-get install python3-pyaudio. Using the version-specific pip ensures the package gets installed directly into your 3.6.5 site-packages directory.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 06:51:27