Pypisoundmicro import error

I’m trying to read an encoder in Python following the docs here. This is my script (perhaps there are mistakes in there, but for now I need to get over the basic error of importing the pypisoundmicro module):

#!/usr/bin/env python3

import pypisoundmicro as psm
from time import sleep

enc = psm.Encoder.setup(psm.ElementName.randomized(),
                        psm.Pin.B03,
                        psm.PinPull.UP,
                        psm.Pin.B04,
                        psm.PinPull.UP)

while True:
    try:
        print(f"enc val: {enc.get_value()}")
        sleep(0.5)
    except KeyboardInterrupt:
        exit()

When I run it, I get the following:

Traceback (most recent call last):
  File "/home/patch/Scripts/./enc_test.py", line 3, in <module>
    import pypisoundmicro as psm
  File "/usr/lib/python3/dist-packages/pypisoundmicro/__init__.py", line 1, in <module>
    from .element import Element
  File "/usr/lib/python3/dist-packages/pypisoundmicro/element.py", line 1, in <module>
    from .swig import pypisoundmicro as psm
ImportError: cannot import name 'pypisoundmicro' from 'pypisoundmicro.swig' (/usr/lib/python3/dist-packages/pypisoundmicro/swig/__init__.py)

Any ideas?

Thank you for the report, this was a .deb packaging bug when rebuilding for Debian trixie - I have just released a fix, available from pypisoundmicro version 1.0.1-3.

To get the fix, do:

sudo apt update
sudo apt install pypisoundmicro

Doing sudo apt update gave me this:

E: Release file for http://deb.debian.org/debian-security/dists/bookworm-security/InRelease is not valid yet (invalid for another 2d 8h 57min 13s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/bookworm-updates/InRelease is not valid yet (invalid for another 2d 19h 23min 14s). Updates for this repository will not be applied.
E: Release file for http://archive.raspberrypi.com/debian/dists/bookworm/InRelease is not valid yet (invalid for another 1d 5h 2min 0s). Updates for this repository will not be applied.

sudo apt install pypisoundmicro returned that it is installed in the latest version. I guess it’s related to the above errors. I’ll have to wait a couple of days, according to the error?

BTW, have you release a PatchBox OS based on Trixie?