TransWikia.com

Streamlit widgets doesn't display in Jupyter Notebook

Data Science Asked on September 4, 2021

I’m trying to create streamlit widgets in Jupyter Notebook but when executing the following code nothing happens.

import numpy as np
import streamlit as st

age = st.selectbox("Choose your age: ", np.arange(18, 66, 1))

According to the following article a SelectBox like this should be created.

enter image description here
But in my code I only get to know that print(age) is 18. What am I doing wrong?

One Answer

You don't run the code from a notebook. You create a python script with your code and then use this command from a shell: streamlit run yourfile.py the output will show up in the shell

enter image description here

Reason for this is that streamlit runs on the main thread so it would block the jupyter kernal, you won't be able to use the notebook while the streamlit app is running. However, if you really want to stay inside Jupyter to run the app, you can run the command in a cell, like this !streamlit run yourfile.py

Answered by Donald S on September 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP