Summary
Streamlit seems to require Altair.v4 so not working with v5?
Steps to reproduce
Code snippet:
pip install altair==5.0.0rc1
streamlit run main.py
Traceback (most recent call last):
File "/usr/local/bin/streamlit", line 5, in <module>
from streamlit.web.cli import main
File "/usr/local/lib/python3.9/site-packages/streamlit/__init__.py", line 55, in <module>
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File "/usr/local/lib/python3.9/site-packages/streamlit/delta_generator.py", line 45, in <module>
from streamlit.elements.arrow_altair import ArrowAltairMixin
File "/usr/local/lib/python3.9/site-packages/streamlit/elements/arrow_altair.py", line 36, in <module>
from altair.vegalite.v4.api import Chart
ModuleNotFoundError: No module named 'altair.vegalite.v4'
Expected behavior:
Any way we can use altair.v5 with Streamlit or when can we expect support for altair.v5?
Debug info
Streamlit, version 1.16.0
Python 3.10.9
Mats_Johansson:
altair==5.0.0rc1
Itβs only a RC, was released only 5 days ago and has no official release yet, so maybe youβre expecting a bit too much?
Thanks, no problems, a long shot so expectations are low Just some new nice features in v5 Iβl like to use and a manual install of v5 is too messy.
Hi, we are aware that altair v5 is not going to work with streamlit as of right now:
opened 07:48AM - 03 Mar 23 UTC
type:bug
status:confirmed
priority:P0
feature:st.altair_chart
### Checklist
- [X] I have searched the [existing issues](https://github.com/st⦠reamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.
### Summary
The [first release candidate for Altair 5](https://github.com/altair-viz/altair/issues/2937) was just released on pip. Streamlit does currently not work for Altair 5 as it imports from `altair.vegalite.v4` which does no longer exist. I assume this was done to prevent Streamlit from breaking once Altair 5 was released. However, we decided to no longer support previous vegalite versions and so these imports will need to be changed to import directly from the top-level `altair` module.
You can find the full release notes [here](https://altair-viz.github.io/releases/changes.html#version-5-0-0-unreleased). For context on why we removed support for previous vegalite versions see https://github.com/altair-viz/altair/issues/2817.
### Reproducible Code Example
```Python
import streamlit as st
import pandas as pd
import numpy as np
import altair as alt
chart_data = pd.DataFrame(
np.random.randn(20, 3),
columns=['a', 'b', 'c'])
c = alt.Chart(chart_data).mark_circle().encode(
x='a', y='b', size='c', color='c', tooltip=['a', 'b', 'c'])
st.altair_chart(c, use_container_width=True)
```
### Steps To Reproduce
1. Install Altair 5 rc1 with `pip install altair==5.0.0rc1`
1. Execute reproducible example
### Expected Behavior
Streamlit app starts and Altair chart shows up as it has done with Altair 4
### Current Behavior
```
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import streamlit as st
2 import pandas as pd
3 import numpy as np
File ~/.local/lib/python3.11/site-packages/streamlit/__init__.py:55
52 # Give the package a version.
53 __version__ = _STREAMLIT_VERSION_STRING
---> 55 from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
56 from streamlit.proto.RootContainer_pb2 import RootContainer as _RootContainer
57 from streamlit.runtime.caching import (
58 cache_resource as _cache_resource,
59 cache_data as _cache_data,
60 experimental_singleton as _experimental_singleton,
61 experimental_memo as _experimental_memo,
62 )
File ~/.local/lib/python3.11/site-packages/streamlit/delta_generator.py:43
40 # DataFrame elements come in two flavors: "Legacy" and "Arrow".
41 # We select between them with the DataFrameElementSelectorMixin.
42 from streamlit.elements.arrow import ArrowMixin
---> 43 from streamlit.elements.arrow_altair import ArrowAltairMixin
44 from streamlit.elements.arrow_vega_lite import ArrowVegaLiteMixin
45 from streamlit.elements.balloons import BalloonsMixin
File ~/.local/lib/python3.11/site-packages/streamlit/elements/arrow_altair.py:36
34 import altair as alt
35 import pandas as pd
---> 36 from altair.vegalite.v4.api import Chart
37 from pandas.api.types import infer_dtype, is_integer_dtype
38 from typing_extensions import Literal
ModuleNotFoundError: No module named 'altair.vegalite.v4'
```
### Is this a regression?
- [ ] Yes, this used to work in a previous version.
### Debug info
- Streamlit version:
- Python version:
- Operating System:
- Browser:
- Virtual environment:
### Additional Information
_No response_
### Are you willing to submit a PR?
- [ ] Yes, I am willing to submit a PR!
3 Likes