Unable to launch Streamlit app

When I try to access my Streamlit app via browser, I’m seeing this error straightaway
It used to work before but this error started showing up suddenly.

I’m totally stuck on this. Any help would be greatly appreciated,

much thanks

Streamlit v1.29.0
Python version: 3.9.12

RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.

Traceback:

File "/usr/local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)File "/code/app/site_streamlit/streamlit_app.py", line 7, in <module>
    from stpyvista import stpyvistaFile "/usr/local/lib/python3.9/site-packages/stpyvista/__init__.py", line 8, in <module>
    import panel as pnFile "/usr/local/lib/python3.9/site-packages/panel/__init__.py", line 50, in <module>
    from . import chat  # noqaFile "/usr/local/lib/python3.9/site-packages/panel/chat/__init__.py", line 33, in <module>
    from .feed import ChatFeed  # noqaFile "/usr/local/lib/python3.9/site-packages/panel/chat/feed.py", line 22, in <module>
    from ..io.resources import CDN_DISTFile "/usr/local/lib/python3.9/site-packages/panel/io/__init__.py", line 9, in <module>
    from .document import (  # noqaFile "/usr/local/lib/python3.9/site-packages/panel/io/document.py", line 47, in <module>
    WRITE_LOCK = asyncio.Lock()File "/usr/local/lib/python3.9/asyncio/locks.py", line 81, in __init__
    self._loop = events.get_event_loop()File "/usr/local/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'

Dockerfile.streamlit

# app/Dockerfile
FROM --platform=linux/amd64 python:3.9

# FROM python:3.9

WORKDIR /code/app

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    cmake \
    libgl1-mesa-glx \
    libxrender1 \
    xvfb \
    && rm -rf /var/lib/apt/lists/*

#RUN git clone https://github.com/streamlit/streamlit-example.git .

COPY . /code/app

RUN pip3 install -r site_streamlit/requirements-streamlit.txt

RUN pip install --user --upgrade stpyvista panel
RUN pip install --user --upgrade streamlit

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "site_streamlit/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

requirements-streamlit.txt

altair
pandas
streamlit
stpyvista
pythreejs
pyvista
ipywidgets
numpy
plotly
numpy-stl
stl
trame_vtk
trame

However, I’m able to run the application when I start the app as follows

streamlit run site_streamlit/streamlit_app.py

But it fails when I start it using docker.

1 Like

UPDATE:

I was able to fix this by downgrading Python version to 3.8

Same problem using stpyvista :dizzy_face: