Rpy2 does not work with streamlit
See original GitHub issueSummary
One can not use the package Rpy2 to call R function from within streamlit. Importing the rpy2 package crashes with an “ValueError: signal only works in main thread”
Steps to reproduce
Code snippet:
import streamlit as st
import rpy2.robjects as robjects
Expected behavior:
Importing the rpy2 package
Actual behavior:
Importing the rpy2 package crashes with an “ValueError: signal only works in main thread”
Is this a regression?
Do not know, never tried before.
Debug info
- Streamlit version: 0.74.1
- Python version: (3.8
- Using Conda
- OS version: Ubuntu 20
- Browser version: Chrome 87.0.4280.141
Additional information
I was told to open this issue in the discussion forum, see https://discuss.streamlit.io/t/using-rpy2-within-streamlit/8812
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
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...
Read more >Using rpy2 with streamlit - python - Stack Overflow
I am trying to build an app by using python and rpy2. ... When I use the code in Jupyter notebook it is...
Read more >How to run R and Python together in a Streamlit app - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >How to Deploy Streamlit Apps on RStudio Connect - R-bloggers
Streamlit is a fairly new framework for data science web applications that has taken the data science world by storm. It allows creating ......
Read more >Python application deployment with RStudio Connect: Streamlit
RStudio Connect is a platform which is well known for providing the ability to deploy and share R applications such as Shiny apps...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Otherwise I don’t think that there is any reason R would (or could) keep running after the Python process ends. R is embedded in the Python process. Think of it as a C library called from the Python process.
I am not familiar enough with Streamlit, but I suspect that importing
streamlit
has side effects (beyond loading Python modules and packages). One of them is that one or several threads are created and the rest of the code in your Python module (that is source file) will be evaluated by the thread(s).If the case, changing the order of imports might clear the warning message you are seeing. Try changing
to