Using rpy2 within Streamlit

Hello,

I’m trying to use the rpy2 package to call R functions from within Streamlit, but it does not even manage to import the rpy2 package but crashes with an
“ValueError: signal only works in main thread”

    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))

Here is the minimal example:
import streamlit as st import rpy2.robjects as robjects

Does anyone know how to solve this?
Thank you very much.

Hi @christophBoerlin, welcome to the Streamlit community!

I suspect the issue here might be that rpy2 might want to run from the main Python thread, and Streamlit executes the user script on a separate thread.

Would you mind opening a GitHub issue for this so that we don’t lose track?

1 Like