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.
But in my code I only get to know that print(age) is 18. What am I doing wrong?
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
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
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP