1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Websocket error when running "streamlit hello" on localhost

Discussão em 'Python' iniciado por Stack, Setembro 5, 2025.

  1. Stack

    Stack Membro Participativo

    Streamlit hello opens up a browser with a silhouette of some flashing page elements, kind of looks like it's trying to load but can't connect. The command line I used to run streamlit hello shows a websocket error. Chrome also shows a websocket error in the developer tab. The error messages in cmd and the browser both repeat continuously, reoccurring every few seconds while the process runs.

    cmd:

    streamlit hello


    browser:

    http://localhost:8501/


    Command line error:

    2024-11-10 12:57:40.144 Uncaught exception
    Traceback (most recent call last):
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\site-packages\tornado\http1connection.py", line 278, in _read_message
    delegate.finish()
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\site-packages\tornado\routing.py", line 268, in finish
    self.delegate.finish()
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\site-packages\tornado\web.py", line 2399, in finish
    self.execute()
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\site-packages\tornado\web.py", line 2421, in execute
    self.handler = self.handler_class(
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\site-packages\tornado\websocket.py", line 220, in __init__
    super().__init__(application, request, **kwargs)
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\site-packages\tornado\web.py", line 214, in __init__
    super().__init__()
    File "C:\Users\myUsername\AppData\Local\Programs\Python\Python310\lib\typing.py", line 1422, in _no_init_or_replace_init
    cls.__init__(self, *args, **kwargs)
    TypeError: WebSocketHandler.__init__() missing 2 required positional arguments: 'application' and 'request'


    Chrome developer tab error:

    main.754d974e.js:19 WebSocket connection to 'ws://localhost:8501/\_stcore/stream' failed:
    connectToWebSocket @ main.754d974e.js:19

    WebsocketConnection WebSocket onerror
    a @ mainl.754d974e.js:10


    I am using Python 3.10. Streamlit is a fresh install with pip, which I also updated.

    I am running WLS Ubuntu (Linux subsystem) on my machine, but I don't think that should be relevant since Python is installed on windows and all the commands and browsers I am using are on my main windows system.

    I tried turning off Norton antivirus stuff. I tried turning off all Chrome extensions and also tried the same in Edge. I tried creating a Python virtual environment. I tried running the command prompt as an administrator.

    I did google the error message and that is how I found the list of resolutions that I mentioned as having already tried. Many of the suggestions relate to writing custom code, but I'm just executing the built-in "hello world" feature of streamlit without any custom work. I don't see how TLS could be the cause as I'm not using https to connect in the browser. The closest thing to my error that I found was the below, but it does not lead to a resolution: github.com/streamlit/streamlit/issues/9140

    This is some kind of basic environment setup issue I feel, because it is a built-in hello world function within streamlit.

    Here is how I created and setup my virtual environment:

    python -m venv strl_venv
    strl_venv\Scripts\activate.bat
    pip install streamlit
    python -m streamlit hello


    This did not solve the problem.

    Continue reading...

Compartilhe esta Página