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?