I want to install pyaudio on my RPi 4 that has 64bit Bullseye 11.2.

According to https://makersportal.com/blog/2018/8/23/recording-audio-on-the-raspberry-pi-with-python-and-a-usb-microphone I should do

sudo apt install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev

however I get

E: Unable to locate package libportaudio0

pyaudio actually recognises my I2S microphone

snd_rpi_i2s_card: simple-card_codec_link snd-soc-dummy-dai-0 (hw:1,0)

but reading sound from it goes nowhere.

I know this worked on 32-bit rRspberry Pi OS. Is this a 64-bit OS problem? How to solve it?

  • It looks like you followed the suggestions at the top of that thread, which were written 9+ years ago. I would try the updated suggestions at the bottom, which are much newer.
    – goldilocks
    Commented Mar 6, 2022 at 16:43
  • @goldilocks Later instruction actually install less packages. But it does not work.. BTW, newer sites also use the same instructions: makersportal.com/blog/2018/8/23/…
    – Pygmalion
    Commented Mar 6, 2022 at 16:49
  • "I know this worked on 32bit raspberry OS" -> There's no libportaudio0 in the 64-bit version whereas there is in the "oldstable" buster (v10) 32-bit. "oldstable" means imported from the previous release, stretch (v9).
    – goldilocks
    Commented Mar 6, 2022 at 17:33
  • I notice there is a python-pyaudio package in buster oldstable as well -- but including 64-bit. Have you tried that? It should pull in dependencies for you, unless the package is broken. apt show python-pyaudio on buster 64-bit gives libportaudio2 <- 2 not 0, which should be available.
    – goldilocks
    Commented Mar 6, 2022 at 17:35
  • @goldilocks I am sorry I don't understand you completely. I was able to install libportaudio2. The problem is that it is not working. The pyaudio recognises I2S microphone, but never finishes while _stream.get_read_available() < sampnumb.
    – Pygmalion
    Commented Mar 6, 2022 at 19:41

2 Answers 2


The first problem is that libportaudio is not available in the 64-bit RpiOS.

The deeper problem is that the advice you have been following is perhaps not very good -- I won't say definitely, because I'm not a user of pyaudio, but it smells like it a bit. My major reason for suspecting this is that there is a python-pyaudio package available in 64 (and 32) -bit, and has been at least since buster and most likely for a long time before that.

Yet the article you link does not mention this even once, which implies the author was not aware and did not have a good understanding of linux package management systems. The python module is pyaudio, so if it is available in the distro, very likely that is in the package name, and in fact there is a simple logic that can be observed in python package names such that we might assume this package is most likely called python-pyaudio. But let's just search for pyaudio first:

> apt search pyaudio
Sorting... Done
Full Text Search... Done
python-pyaudio/oldstable 0.2.11-1+b2 arm64
  Python bindings for PortAudio v19

python-pyaudio-doc/oldstable,oldstable 0.2.11-1 all
  Documentation for Python bindings for PortAudio v19

python3-pyaudio/oldstable 0.2.11-1+b2 arm64
  Python3 bindings for PortAudio v19

There are a couple more packages in the list returned that I have left off. It is interesting that these are in oldstable and not the stable; this is a buster system so it means that package has been there since stretch, which is going back 4-5 years.1 The version listed here is explicitly for "PortAudio v19", which if we dig into their website a bit reveals that this is the current version.

It is important to understand that if the package manager installs something in its default mode, that software is ready to use. A major purpose of a package management system is that it manages dependencies for you.

There is both a python and python3 package available. Here's more about the latter:

> apt show python3-pyaudio
Package: python3-pyaudio
Version: 0.2.11-1+b2
Priority: optional
Section: python
Source: python-pyaudio (0.2.11-1)
Maintainer: Hubert Pham <[email protected]>
Installed-Size: 148 kB
Provides: python3.6-pyaudio, python3.7-pyaudio
Depends: python3 (<< 3.8), python3 (>= 3.6~), python3:any (>= 3.3.2-2~), libc6 (>= 2.17), libportaudio2 (>= 19+svn20101113)
Suggests: python-pyaudio-doc (>= 0.2.11)
Homepage: https://people.csail.mit.edu/hubert/pyaudio/
Download-Size: 25.3 kB
APT-Sources: http://deb.debian.org/debian buster/main arm64 Packages
Description: Python3 bindings for PortAudio v19

There are dependencies there including libportaudio2, which presumably replaced libportaudio0. Again: You do not have to go through the list of dependencies and install them all one at a time manually. By installing python[3]-pyaudio, those dependencies will be included.

So, what you should have tried first was just:

sudo apt install python3-pyaudio

Presuming you want the python3 version. I can't promise this does work, but it is not hard to try.

  1. Meaning it was there when that article was written. This is actually good, since it implies that all the rigmarole there was not because the pyaudio package was broken but because the author was not aware it existed.
  • Thanks. I will try your suggestion. Should I first uninstall libportaudio2 libportaudiocpp0 portaudio19-dev? As I am using python2, I guess I need python-pyaudio?
    – Pygmalion
    Commented Mar 7, 2022 at 16:21
  • You shouldn't need to do that; if there is some conflict or problem with having package A and package B at the same time, the package manager will tell you when you go to install package B (presuming you already have A installed). Just note that does not cover things installed some other way (eg. from source or via pip). WRT which package, yes, python-pyaudio is the one for python 2.
    – goldilocks
    Commented Mar 7, 2022 at 16:26
  • What I don't understand, in my naivety, is how python program knows which package to use, libportaudio2 or python-pyaudio?
    – Pygmalion
    Commented Mar 7, 2022 at 16:41
  • libportaudio2 is a compiled shared library not written in python, as PortAudio is not python centric. Many python modules include bits written in C, so that non-python libraries can be used; that's what part of the pyaudio module does. WRT the python interpreter, it will use the pyaudio module installed by the distro package python-pyaudio, but it does not know about or make use of the distro package manager. Ie., libportaudio2 is the actual system library binary, pyaudio uses that under-the-hood, and python-pyaudio is the distro package that includes the pyaudio module.
    – goldilocks
    Commented Mar 7, 2022 at 17:04
  • Unfortunately, I get error E: Unable to locate package python-pyaudio
    – Pygmalion
    Commented Mar 12, 2022 at 21:06

libportaudio0, libportaudio2, libportaudiocpp0 are/were essentially just dependencies on the portaudio19-dev package. But over time libportaudio0 has stopped being a dependency and is no longer needed (source: http://packages.debian.org/bullseye/portaudio19-dev)

Also, since installing the portaudio19-dev package automatically installs the dependencies, one only needs to run

sudo apt install portaudio19-dev

If one just runs this command, everything should work normally.

  • I confirm installing that allows for a smooth pip3 install pyaudio. Thanks
    – jhagege
    Commented Mar 28, 2023 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.