[Python] Runtime Error: No Running Event Loop on Streamlit with Docker

Discussão em 'Python' iniciado por Stack, Maio 11, 2025.

  1. Stack

    Stack Membro Participativo

    • Goal: Trying to build and deploy a streamlit langgraph application
    • Problem: Docker and Streamlit do not play well

    Phase 1: The app I made: https://github.com/tanvircr7/CRAG/

    I first built without docker in mind. I used python virtual environment and everything was working.

    Then I started containerising and the problems started

    This error kept popping up: https://pastebin.com/FsGanN8N

    Phase 2: I deciding to start fresh with docker and then work my way up to the final app

    github link of the new project: https://github.com/tanvircr7/corrective-rag

    Now I just have a simple file upload application.

    When I run it, it starts up on port 8501.

    But The same error keeps popping up: https://pastebin.com/FsGanN8N

    • System: Windows 11 with wsl2
    • Docker Version: 28.0.4 build b8034c0
    • Streamlit Version: 1.45.0
    • Python Version: 3.11.12

    The error code:

    Exception in callback AppSession._on_scriptrunner_event.<locals>.<lambda>() at /usr/local/lib/python3.11/site-packages/streamlit/runtime/app_session.py:518

    handle: <Handle AppSession._on_scriptrunner_event.<locals>.<lambda>() at /usr/local/lib/python3.11/site-packages/streamlit/runtime/app_session.py:518>

    Traceback (most recent call last):
    File "/usr/local/lib/python3.11/site-packages/streamlit/web/bootstrap.py", line 347, in run

    if asyncio.get_running_loop().is_running():
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: no running event loop

    During handling of the above exception, another exception occurred:


    Traceback (most recent call last):
    File "/usr/local/lib/python3.11/asyncio/events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/app_session.py", line 518, in <lambda>
    lambda: self._handle_scriptrunner_event_on_event_loop(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/app_session.py", line 612, in _handle_scriptrunner_event_on_event_loop
    msg = self._create_new_session_message(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/app_session.py", line 742, in _create_new_session_message
    _populate_user_info_msg(imsg.user_info)
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/app_session.py", line 990, in _populate_user_info_msg
    inst = Installation.instance()
    ^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/metrics_util.py", line 228, in instance
    cls._instance = Installation()
    ^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/metrics_util.py", line 236, in __init__
    self.installation_id_v4 = _get_machine_id_v4()
    ^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/metrics_util.py", line 209, in _get_machine_id_v4
    with file_util.streamlit_write(filepath) as output:
    File "/usr/local/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
    ^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/streamlit/file_util.py", line 109, in streamlit_write
    os.makedirs(os.path.dirname(path), exist_ok=True)
    File "<frozen os>", line 215, in makedirs
    File "<frozen os>", line 225, in makedirs
    PermissionError: [Errno 13] Permission denied: '/nonexistent'

    Continue reading...

Compartilhe esta Página