spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
980 stars 145 forks source link

Can't find portaudio in alpine docker container #467

Open FX-Wood opened 1 year ago

FX-Wood commented 1 year ago

I was having trouble locating the portaudio library inside an alpine docker container. It appears that this is because ctypes.util.find_library has trouble finding libraries in some cases. The workaround is to make a symlink to the library without the digit:

apk add portaudio cd /usr/lib && ln -s [library.name.[0-9]] [library.name] I found this solution here: https://bugs.python.org/issue43642

It looks like maybe this issue on the cpython repo has some further discussion: from: https://github.com/python/cpython/pull/18380

Leaving this issue here for anyone else who is looking for a workaround.

example error text (for searches)

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/site-packages/sounddevice.py", line 71, in <module>
    raise OSError('PortAudio library not found')
OSError: PortAudio library not found

libportaudio alpine docker python portaudio

FX-Wood commented 1 year ago

More discussion here: https://github.com/docker-library/python/issues/111 https://github.com/python/cpython/issues/65821