Vega-Altair: A declarative statistical visualization library for Python
raw JSON → 6.0.0 verified Tue May 12 auth: no python install: verified quickstart: stale
Altair is a declarative statistical visualization library for Python, built on top of the powerful Vega-Lite JSON specification. It offers a simple, friendly, and consistent API for creating a wide range of interactive and aesthetically pleasing statistical charts with a minimal amount of code. The library is actively developed, with a current stable version of 6.0.0 and weekly pre-release builds.
pip install altair Common errors
error ModuleNotFoundError: No module named 'altair' ↓
cause The Altair library is not installed in the Python environment.
fix
Install Altair using pip:
pip install altair. error AttributeError: module 'altair' has no attribute 'selection_point' ↓
cause The 'selection_point' attribute is not available in the installed version of Altair.
fix
Upgrade Altair to the latest version:
pip install --upgrade altair. error AttributeError: module 'altair' has no attribute 'Chart' ↓
cause A local file named 'altair.py' is shadowing the Altair library.
fix
Rename or remove the local 'altair.py' file to avoid the naming conflict.
error AttributeError: module 'jsonschema' has no attribute 'Draft7Validator' ↓
cause An outdated version of the 'jsonschema' library is installed.
fix
Upgrade 'jsonschema' to a compatible version:
pip install 'jsonschema>=3.0,<4.0'. error ModuleNotFoundError: No module named 'altair.vegalite.v4' ↓
cause The installed version of Altair does not include the 'vegalite.v4' module.
fix
Ensure compatibility between Altair and dependent libraries by installing compatible versions or upgrading dependent libraries.
Warnings
breaking Altair 6.0.0 officially removes support for Python 3.8. Users should upgrade to Python 3.9 or newer. ↓
fix Upgrade your Python environment to 3.9 or higher. Review `pyproject.toml` or `setup.cfg` for `requires_python` constraints.
breaking Altair 6.0.0 is compiled against Vega-Lite version 6. While largely backward compatible, some advanced or undocumented Vega-Lite features might behave differently or require updates if you were directly manipulating the underlying JSON spec. ↓
fix Consult the Vega-Lite 6 release notes for any specific breaking changes relevant to your custom specifications. Test existing complex charts after upgrading.
breaking The recommended way to access built-in example datasets changed from `from vega_datasets import data` to `from altair.datasets import data` in Altair 6.0.0. Some column names in these datasets might also have changed (e.g., spaces instead of underscores). ↓
fix Update import statements to `from altair.datasets import data`. If encountering `KeyError` for column names, check the dataset documentation or inspect the DataFrame for updated column names.
gotcha Altair charts are primarily designed for display in Jupyter environments (Notebook, Lab, VS Code with Jupyter extension). Outside of these, you may need to configure a specific renderer (e.g., 'mimetype', 'html', 'json', 'altair_saver') to display or save charts. ↓
fix For non-Jupyter environments, ensure you explicitly call `chart.save('chart.html')`, `chart.to_json()`, or configure a renderer like `alt.renderers.enable('altair_saver')` (requires `vl-convert-python`).
breaking Building `vegafusion` (a dependency of Altair) on Alpine Linux environments may fail due to missing `glibc` or `libgcc` components required by Rust/Cargo build tools. This typically manifests as 'Error loading shared library libgcc_s.so.1: No such file or directory' errors during metadata generation. ↓
fix To resolve this, install `libgcc` and `libstdc++` in your Alpine environment or Dockerfile before installing Python packages that rely on Rust extensions. For example, using `apk add libgcc libstdc++`.
Install
pip install "altair[all]" Install compatibility verified last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) all build_error - - - -
3.10 alpine (musl) altair wheel - 0.99s 37.2M
3.10 alpine (musl) all - - - -
3.10 alpine (musl) altair - - 0.95s 37.0M
3.10 slim (glibc) all wheel 18.3s 1.79s 553M
3.10 slim (glibc) altair wheel 3.5s 0.70s 37M
3.10 slim (glibc) all - - 1.70s 525M
3.10 slim (glibc) altair - - 0.66s 37M
3.11 alpine (musl) all build_error - - - -
3.11 alpine (musl) altair wheel - 1.41s 41.2M
3.11 alpine (musl) all - - - -
3.11 alpine (musl) altair - - 1.52s 40.9M
3.11 slim (glibc) all wheel 17.4s 2.97s 572M
3.11 slim (glibc) altair wheel 3.5s 1.23s 41M
3.11 slim (glibc) all - - 2.75s 543M
3.11 slim (glibc) altair - - 1.20s 41M
3.12 alpine (musl) all build_error - - - -
3.12 alpine (musl) altair wheel - 1.36s 32.6M
3.12 alpine (musl) all - - - -
3.12 alpine (musl) altair - - 1.44s 32.3M
3.12 slim (glibc) all wheel 17.0s 3.18s 556M
3.12 slim (glibc) altair wheel 2.9s 1.35s 33M
3.12 slim (glibc) all - - 3.13s 527M
3.12 slim (glibc) altair - - 1.44s 32M
3.13 alpine (musl) all build_error - - - -
3.13 alpine (musl) altair wheel - 1.03s 32.1M
3.13 alpine (musl) all - - - -
3.13 alpine (musl) altair - - 1.10s 31.7M
3.13 slim (glibc) all wheel 17.2s 3.20s 555M
3.13 slim (glibc) altair wheel 3.0s 1.07s 32M
3.13 slim (glibc) all - - 3.22s 526M
3.13 slim (glibc) altair - - 1.14s 32M
3.9 alpine (musl) all build_error - - - -
3.9 alpine (musl) altair wheel - 0.96s 36.7M
3.9 alpine (musl) all - - - -
3.9 alpine (musl) altair - - 0.92s 36.5M
3.9 slim (glibc) all wheel 21.1s 2.15s 527M
3.9 slim (glibc) altair wheel 4.1s 0.90s 37M
3.9 slim (glibc) all - - 1.93s 527M
3.9 slim (glibc) altair - - 0.88s 37M
Imports
- Chart
import altair as alt - data wrong
from vega_datasets import datacorrectfrom altair.datasets import data
Quickstart stale last tested: 2026-04-24
import altair as alt
import pandas as pd
# Sample data
data = pd.DataFrame({
'a': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
'b': [28, 55, 43, 91, 81, 53, 19, 87, 52]
})
# Create a simple bar chart
chart = alt.Chart(data).mark_bar().encode(
x='a',
y='b'
)
chart.show()