ModuleNotFoundError: No module named 'altair.vegalite.v4'

Hi guys!
My app https://spikescape.streamlit.app/ worked great on the streamlit cloud, but crashed today.
I didn’t change anything in the app, and when I tried to reboot an app it throws the following error:

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/arrow_altair.py", line 27, in <module>

    from altair.vegalite.v4.api import Chart

ModuleNotFoundError: No module named 'altair.vegalite.v4'

[15:07:15]  Streamlit server consistently failed status checks

Do you know what could be the reason and how could I fix it?

4 Likes

I installed altair=4 with pip and it worked out. However I still do not understand why altair4 disappeared in the first place. Does anyone has ideas?

4 Likes

Hello,

I was searching the forums for this issue, this actually resolved my issue when making changes to my requirements.txt file by adding ‘altair==4.0’.

Does anyone know why this is a sudden issue?
Was there an update to streamlit cloud?

1 Like

Altair version 5.0.0 was released on 9. May 2023, probably there are some breaking changes.
If you don’t pin the altair version <5 and then perform a reboot/deploy, this issue will hit you.

2 Likes

I had the same issue and the fix of the version worked. Thanks!

1 Like

This should fix the issue:

requirements.txt

altair<5
8 Likes

What version of streamlit are you using?

This error can also happen if the streamlit package is pinned to an older version. In practice, this has been seen to happen if you pin to streamlit==1.17.0 in streamlit.txt, but works if you unpin or change to streamlit==1.22.0

Hi everyone,

I am having the same issue with my streamlit app. I added the altair<5 to my requirement file but still I am not able to run my app.
This is my GitHub requirement repository link:

I tried changing the streamlit version too but got the same result. Please, help. Thanks

  • What is the error message?
  • What do you need pickle5 for?
File "/home/appuser/venv/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'

This is my error and I used PIckle5 to read my prediction model.

Hey Franky!

I wanted to give you an update on the app—it’s running smoothly! I actually realized my mistake. Instead of simply refreshing the app, I needed to reboot the entire thing. It turns out I was confusing those two actions.

I really appreciate your quick response. It’s amazing how supportive the streamlit community is—I’m absolutely loving it!

Thanks again

3 Likes

I have streamlit version 1.18.1 and altair 4.0.0 but still having error ;(
Any reason?

 $ streamlit run app.py
Traceback (most recent call last):
  File "/opt/homebrew/bin/streamlit", line 5, in <module>
    from streamlit.web.cli import main
  File "/opt/homebrew/lib/python3.11/site-packages/streamlit/__init__.py", line 55, in <module>
    from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
  File "/opt/homebrew/lib/python3.11/site-packages/streamlit/delta_generator.py", line 43, in <module>
    from streamlit.elements.arrow_altair import ArrowAltairMixin
  File "/opt/homebrew/lib/python3.11/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'
 ~/files/chatGPT/langchain-ask-pdf   main ●            1 ↵  5647  22:09:34
 $ pip show streamlit
Name: streamlit
Version: 1.18.1
Summary: The fastest way to build data apps in Python
Home-page: https://streamlit.io
Author: Snowflake Inc
Author-email: hello@streamlit.io
License: Apache License 2.0
Location: /Users/azizulhaque/.local/share/virtualenvs/streamlit-gDBanFGa/lib/python3.11/site-packages
Requires: altair, blinker, cachetools, click, gitpython, importlib-metadata, numpy, packaging, pandas, pillow, protobuf, pyarrow, pydeck, pympler, python-dateutil, requests, rich, semver, toml, tornado, typing-extensions, tzlocal, validators
Required-by:
 ~/files/chatGPT/langchain-ask-pdf   main ●              ✔  5648  22:09:49
 $ pip show altair
Name: altair
Version: 4.0.0
Summary: Altair: A declarative statistical visualization library for Python.
Home-page: http://altair-viz.github.io
Author: Brian E. Granger / Jake VanderPlas
Author-email: jakevdp@gmail.com
License: BSD 3-clause
Location: /Users/azizulhaque/.local/share/virtualenvs/streamlit-gDBanFGa/lib/python3.11/site-packages
Requires: entrypoints, jinja2, jsonschema, numpy, pandas, toolz
Required-by: streamlit

Hey all :wave:,

Wanted to hop in and say that @Franky1 is right and there were breaking changes in Altair 5 for Community Cloud.

In the short term, the best solution would be to:
Either: pin altair < 5 or upgrade streamlit to >=1.20.0

In the medium term, we’re building in support for Altair 5. Stay tuned!

4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.