Streamlit Spaces broken by altair requirement problem

Streamlit older spaces I have been compiling lately are all returning this new error about altair conflict, possibly related to 3.8 python distrib changes - can you fix this dependency issue in the docker distrib image?


===== Build Queued at 2023-05-19 11:33:53 / Commit SHA: 2e237c0 =====

→ FROM Docker
DONE 0.0s

→ RUN sed -i ‘s http://deb.debian.org http://cdn-aws.deb.debian.org g’ /etc/apt/sources.list && sed -i ‘s http://archive.ubuntu.com http://us-east-1.ec2.archive.ubuntu.com g’ /etc/apt/sources.list && sed -i ‘/security/d’ /etc/apt/sources.list && apt-get update && apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx && rm -rf /var/lib/apt/lists/* && git lfs install
CACHED

→ RUN --mount=target=pre-requirements.txt,source=pre-requirements.txt pip install --no-cache-dir -r pre-requirements.txt
CACHED

→ RUN useradd -m -u 1000 user
CACHED

→ RUN --mount=target=requirements.txt,source=requirements.txt pip install --no-cache-dir -r requirements.txt
CACHED

→ RUN pip install --no-cache-dir pip==22.3.1 && pip install --no-cache-dir datasets “huggingface-hub>=0.12.1” “protobuf<4” “click<8.1”
CACHED

→ RUN --mount=target=/root/packages.txt,source=packages.txt sed -i ‘s http://deb.debian.org http://cdn-aws.deb.debian.org g’ /etc/apt/sources.list && sed -i ‘s http://archive.ubuntu.com http://us-east-1.ec2.archive.ubuntu.com g’ /etc/apt/sources.list && sed -i ‘/security/d’ /etc/apt/sources.list && apt-get update && xargs -r -a /root/packages.txt apt-get install -y && rm -rf /var/lib/apt/lists/*
CACHED

→ COPY --link --chown=1000 --from=lfs /app /home/user/app
CACHED

→ RUN pip install --no-cache-dir streamlit==1.17.0
CACHED

→ WORKDIR /home/user/app
CACHED

→ COPY --link --chown=1000 ./ /home/user/app
DONE 0.0s

→ Pushing image
DONE 1.2s

→ Exporting cache
DONE 1.5s

===== Application Startup at 2023-05-19 11:34:04 =====

Traceback (most recent call last):
File “/home/user/.local/bin/streamlit”, line 5, in
from streamlit.web.cli import main
File “/home/user/.local/lib/python3.8/site-packages/streamlit/init.py”, line 55, in
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File “/home/user/.local/lib/python3.8/site-packages/streamlit/delta_generator.py”, line 45, in
from streamlit.elements.arrow_altair import ArrowAltairMixin
File “/home/user/.local/lib/python3.8/site-packages/streamlit/elements/arrow_altair.py”, line 36, in
from altair.vegalite.v4.api import Chart
ModuleNotFoundError: No module named ‘altair.vegalite.v4’

Here is another example space where it occurs. I tried putting altair into requirements.txt but think it has to be a fix to pre-requirements.txt or the streamlit docker.

This example for my STEM teaching for instance has minimal includes so close to plain streamlit. Arrow->Altair might conflict since it needs the v2 version of Altair I think (rather than attempted v4)

Function signature[source]
st.altair_chart(altair_chart, use_container_width=False, theme=“streamlit”)
Parameters
altair_chart (altair.vegalite.v2.api.Chart) The Altair chart object to display.

theme=“streamlit”)ModuleNotFoundError: No module named ‘altair.vegalite.v4

Thanks and good luck on fixing! Much appreciated and cool docker flow.
–Aaron

Runtime error
Traceback (most recent call last):
File “/home/user/.local/bin/streamlit”, line 5, in
from streamlit.web.cli import main
File “/home/user/.local/lib/python3.8/site-packages/streamlit/init.py”, line 55, in
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File “/home/user/.local/lib/python3.8/site-packages/streamlit/delta_generator.py”, line 45, in
from streamlit.elements.arrow_altair import ArrowAltairMixin
File “/home/user/.local/lib/python3.8/site-packages/streamlit/elements/arrow_altair.py”, line 36, in
from altair.vegalite.v4.api import Chart
ModuleNotFoundError: No module named ‘altair.vegalite.v4’

just for reference here is the solution

1 Like