Running Jupyter within Streamlit app

Hi all.

I’ve seen a lot of resources for how to run a Streamlit app from a notebook, or convert a notebook into a Streamlit app.

However, I want to do the opposite. I want to embed a Jupyter notebook environment into my Streamlit app so that my users can run custom code from within the app.

Is this possible? Can someone share how they think I might be able to accomplish this?

3 Likes

Hi @ryanblumenow - did you manage to achieve your goal ? if so could you share how you did it?

One easy way to get the basic functionality is to use jupyterlite:
Code: JupyterLab-in-streamlit/streamlit_app.py at main · CharlyWargnier/JupyterLab-in-streamlit · GitHub
App: https://charlywargnier-jupyterlab-in-streamlit-streamlit-app-21bvhb.streamlitapp.com/

(ht @Charly_Wargnier)

2 Likes

That’s really cool. But I think it would not work in my particular case. We have an air-gapped application… so no access to jupyterlit.github.io

Plus we would like the user to be able to query a db which is on prem as well, but reachable by the streamlit app.

The streamlit app is running in a docker container and I’m wondering if it would be possible to have a jupyter server running in a separate container and have that embedded in the streamlit app? Am I talking nonsense?

I’m not sure if there’s a way to do that, sorry. One similar thing you can do is something like streamlit-playground/streamlit_app.py at main · blackary/streamlit-playground · GitHub, which gives you a code editor, and then the resulting streamlit app below it. I have the editor hidden by requiring a special password to be passed as a query parameter in the URL, but that’s just because I have it publicly accessible. The end result is something that looks like this

That’s a nice one. Thanks for sharing. I would still prefer to offer them the notebook feel/experience but this is a good alternative.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.