I just installed Streamlit. I wrote a hello world program. But no new tab opened in my browser, so I couldn’t see the result of my program.
HI @p0l4r! Welcome to the community.
I’m sorry you had trouble seeing your app. So that I can help you better, could you please share the following information with me:
- Are you running this example on a local machine (e.g. your laptop) or a remote machine (e.g. an Amazon EC2 instance)?
- Does the same behavior occur when you run
streamlit hellorather than your own script?
- Have you tried manually going the addresses displayed when you launch Streamlit? For example, when I see:
$ streamlit hello You can now view your Streamlit app in your browser. Local URL: http://localhost:8501 Network URL: http://192.168.1.51:8501
so you would point your browser to
- What browser and operating system are you using?
- I am running the example on my personal computer ( local machine ).
- I ran streamlit hello.
- I have tried that. Didn’t work.
- I am using Windows 10 as OS and Google Chrome as web browser.
That’s super strange.
To debug, I would like to see if the Python package we use to open the browser is working on your system. Can you try the command below in a Python interpreter (using the same environment you use for Streamlit):
import webbrowser webbrowser.open('http://streamlit.io')
And just for completeness, can you tell us what this prints out:
import platform platform.system()
- when I used-
A new tab opened in my browser and I got redirected to http://streamlit.io
- when I used-
Great, so we can eliminate that hypothesis
Oh, I forgot to ask: can you try printing the output of
platform.system() to the console?
Here it is
That’s very strange. What Streamlit does is just combine those two commands like this:
if platform.system() == 'Windows': webbrowser.open(streamlit_url)
So if that’s not working, I’m at a loss…
Actually, re-reading the thread I see you said that manually going the address displayed when you launch Streamlit doesn’t work. This makes me think the Windows Firewall may be blocking Streamlit.
Can you look at the Firewall settings and see if Streamlit is allowed to access port 8501?
Can you please tell me how I do that ? I have tried different method, allowed streamlit application through firewall , but it is not working. I think I am not doing it right.
Sorry for the delay. I’ve been on-and-off trying to find some docs on how to do that, but could not find anything that looked promising. (Did I mention I’m not a Windows user? )
So I have a couple more questions to help debug:
When you run
python -m http.server 8000and go to
http://localhost:8000on your browser, does it show a file listing? This will tell me whether the problem is Streamlit-specific or related to any server running on your machine.
(After you try the above, press Ctrl-C on the terminal)
streamlit helloand then run this on another terminal:
netstat -an | find "8501"
If you see something that says “LISTENING” that means Streamlit started correctly. For example:
TCP 0.0.0.0:8501 0.0.0.0:0 LISTENING
streamlit hellothen open
127.0.0.1:8501on your browser. Does that work? If so, this command should make
netsh http add iplisten 127.0.0.1
This is what happens.
After running streamlit hello I tried the command netstat -an | find “8501”. It showed nothing.
No it does not work.
That’s strange. So just to make 100% sure, can you confirm that these are the steps you took:
- Open a terminal and a Python environment where Streamlit is installed.
- Open another terminal
netstat -an | find "8501"
Dear Sir, I tried running streamlit hello, but nothing happened. Then I tried to run a longer script, still same.
Install Python 3.7.5 it’s a perfect solution for Windows Users
Thanks for the screenshot — that actually clarifies things.
It looks like you’re running your Streamlit app
st.py straight from a Python console. That’s not how you’re supposed to run those.
Instead you should call
streamlit run like this in a terminal:
streamlit run st
I hope that helps!
I usually use the python IDLE. I also tend to run from the IDLE by pressing the F5. My usual way of running python script didn’t work. Can you please tell me how to run this from terminal ? I tried once, but didn’t work from terminal. My file is in the J:/ drive , in st folder.
Can you please give the exact command or way to run the code from the terminal ?
And , I have checked, streamlit is installed.
I think the problem is that Streamlit is being installed in a Python environment that is not accessible from the Windows terminal. To solve this I’d have to know exactly how you installed Python, which on Windows could be in a thousand different ways — and I’m definitely not an expert in every single one of them
On Windows, my preferred way to use Python is with Anaconda. It makes it super easy to create new Python environments, manage them, install packages, open a terminal pointing to the right environment, and so on.
Here are the installation instructions for that: https://docs.anaconda.com/anaconda/install/windows/
Once that’s installed, you can open the Anaconda Navigator, create a new environment, install Streamlit in there, and then do this to open a terminal where Streamlit will work:
(in the screenshot above my environment is called “Orange” for some reason! Yours can be named whatever you want)
I installed streamlit using pip. What should one do for pip ? Just wanted to know for future reference.