Registry / data / altair

altair

JSON →
library6.2.2pypypi✓ verified 25d ago

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
INSTALL
IMPORT
SIG · ALTAIR
A
altair
datapythonv6.2.2
Install
10.4s avg
Import
1761ms
Disk
561MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
✓ 10.65s
py 3.11
1/2 runs
✓ 10.15s
py 3.12
1/2 runs
✓ 9.45s
py 3.13
1/2 runs
✓ 9.75s
py 3.9
1/2 runs
✓ 11.9s
561MB installed
● package 561MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Chart
import altair as alt
Standard convention for Altair imports.
data
from altair.datasets import data
from vega_datasets import data
As of Altair v6.0.0, the recommended way to access built-in datasets is via `altair.datasets`. The `vega_datasets` package is still functional but less integrated for new examples.

This quickstart demonstrates how to create a basic bar chart using Altair with a pandas DataFrame. It defines a DataFrame, then uses `alt.Chart()` to specify the data, `mark_bar()` to choose the chart type, and `encode()` to map data columns to visual properties (x and y axes). The `.show()` method attempts to render the chart in a compatible environment.

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()
Debug
Known issues
breakingAltair 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.
affects: 6.0.0 and above
breakingAltair 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.
affects: 6.0.0 and above
breakingThe 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.
affects: 6.0.0 and above
gotchaAltair 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`).
affects: All versions
breakingBuilding `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++`.
affects: 6.0.0 and above
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'altair'
The Altair library is not installed in the Python environment.
fix
Install Altair using pip: `pip install altair`.
AttributeError: module 'altair' has no attribute 'selection_point'
The 'selection_point' attribute is not available in the installed version of Altair.
fix
Upgrade Altair to the latest version: `pip install --upgrade altair`.
AttributeError: module 'altair' has no attribute 'Chart'
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.
AttributeError: module 'jsonschema' has no attribute 'Draft7Validator'
An outdated version of the 'jsonschema' library is installed.
fix
Upgrade 'jsonschema' to a compatible version: `pip install 'jsonschema>=3.0,<4.0'`.
ModuleNotFoundError: No module named 'altair.vegalite.v4'
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.
Upgrade
Version history
6.2.2latest on PyPI · released Jun 23, 2026
Audit
Dependencies
pythonrequiredRuntime environment
entrypointsrequiredRequired for package entry points
jsonschemarequiredRequired for schema validation
numpyrequiredTypically used for data handling; implicitly installed with pandas
pandasrequiredCommonly used for data structures (DataFrames)
toolzrequiredFunctional utilities
vega_datasetsoptionalProvides sample datasets for examples and tutorials
ipythonoptionalEnhanced interactive Python shell, often used with Jupyter
jupyteroptionalFor rendering charts in Jupyter notebooks/Lab
jupyterlaboptionalFor rendering charts in Jupyter notebooks/Lab
polarsoptionalAlternative DataFrame library for data handling
pyarrowoptionalData serialization and interoperability, sometimes used with Polars
vl-convert-pythonoptionalEnables PNG and SVG export of Altair charts
Agent activity
66 hits · last 30 days
node
58
OpenAI (training)
2
Resources
altair — pip install altair · libregistry