Streamlit local host shows up blank

Hey guys I am having trouble seeing any of the code I produced in VS code onto my streamlit local host, its just a blank page. I have saved everything, check the path, closed out and opened new terminal/window/vs code but nothing seems to work. Is it because I don’t have a main function or what else could it be. Worked all night to write the code and sucks that I can’t see if I did it right. I am running python 3.8.8, VS code and I don’t know if it matters but I have had trouble downloading software and applications on my 2021 MacBook Pro with the M1 chip.


Hi @joel.alba75, welcome to the Streamlit community!

No, a main function is not required.

The first thing I would do is comment out your entire file, and just put back two lines:

import streamlit as st

"Hello, World!"

If you hit save, then run streamlit run app.py, do you get a result?

Best,
Randy

Thanks for getting back to me Randy, I tried that and still get a blank page.

  1. Are you connected to the internet?
  2. If so, does anything show up in the Developer Tools console in the browser?

Try pasting the URL of your localhost into a Chrome tab. For me it solved the problem

1 Like

same as the problem i had. however I found the problem at the end of the application I forgot to add this

if __name__ == '__main__':
    main()

Hi @randyzwitch, opening up this discussion again as I’m facing the same issue. I try to run the simple hello world example you posted earlier, and the page on my browser appears blank. I’ve fixed the launch.json file based on posts on this forum to contain:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python: Streamlit",
            "type": "python",
            "request": "launch",
            "module": "streamlit",
            "args": [
                "run", 
                "${file}"
            ]
        }
    ]
}

This is what I see in the terminal when I run streamlit run test.py

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.


  You can now view your Streamlit app in your browser.

  Network URL: http://10.162.0.2:8501
  External URL: http://34.118.133.199:8501

Could you please help me resolve this? For reference, I am using VS Code for this, with the following environment:

name: minimal-streamlit

channels:

- defaults

- conda-forge

- ericmjl

dependencies:

- python=3.8

- conda

- scikit-learn

- scipy

- pandas

- numpy

- matplotlib

- pip

- pylint

- pydocstyle

- flake8

- black

- hvplot

- bokeh

- holoviews

- pip:

- streamlit

I pasted in chrome and it works