PortAudio Library Not Found

I wrote my code in Streamlit and I’ve been using “sounddevice” for my app. I placed sounddevice in my requirements.txt in my github repo and also imported it in my streamlit code. It works well in my local Streamlit. However, I keep on getting this error every time I deploy my app in Heroku:

OSError: PortAudio library not found
  File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/ScriptRunner.py", line 314, in _run_script
    exec(code, module.__dict__)
  File "/app/helloworld.py", line 11, in <module>
    import sounddevice as sd
  File "/app/.heroku/python/lib/python3.6/site-packages/sounddevice.py", line 71, in <module>
    raise OSError('PortAudio library not found')

Would anyone know how to go about this? Thank you!

1 Like

Welcome to the forums @emacarayan !

Though we welcome all types of questions related to Streamlit, I feel this is more of a sounddevice/Heroku question than a Streamlit question, I think you’d have a much better chance pinging the Heroku community.

In the Sounddevice installation doc :

If you install the sounddevice module with pip on macOS or Windows, the PortAudio library (with ASIO support on Windows) will be installed automagically. On other platforms, you might have to install PortAudio with your package manager (the package might be called libportaudio2 or similar)

so my guess would be you need to install libportaudio2 this when creating the Heroku worker, maybe someone here knows how to but otherwise the Heroku community is your best bet.

1 Like

Hi @emacarayan – Just here to echo @andfanilo (gratefully) for coming up with the right response for you.

PortAudio is a sound driver that needs to be installed on the operating system level in order for Python libraries to have the ability to hook into it.

When I looked around the web for how to get this installed on Heroku, I kept getting pointed back to this StackOverflow post dealing with installing portaudio on Ubuntu.

In order to have the ability to install libraries on Heroku, it seems you need to bootstrap this ability by installing an “apt buildpack” as mentioned in the official documentation here.

Let us know if you find a way to get portaudio installed on Heroku!

1 Like