Registry / analytics / vega
library4.1.0pypypi✓ verified 88d ago

A Jupyter widget that renders Vega 5 and Vega-Lite 4 specifications. Version 4.1.0 requires Python >=3.8 and works with Jupyter Notebook, JupyterLab, and VSCode. It is typically installed alongside a conda environment for the Vega dependencies. The library is actively maintained on GitHub under the Vega organization.

pip install vega
INSTALL
IMPORT
SIG · VEGA
V
vega
analyticspythonv4.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Vega
✓ from vega import Vega
✗ from vega.widget import Vega
Older API used vega.widget, but vega now exports Vega directly
VegaLite
✓ from vega import VegaLite
✗ from vega.widget import VegaLite
Same as above; vega.widget was deprecated in early 4.x versions

Render a simple Vega-Lite scatter plot in a Jupyter notebook.

from vega import VegaLite data = [{'x': 1, 'y': 2}, {'x': 3, 'y': 4}] spec = { '$schema': 'https://vega.github.io/schema/vega-lite/v4.json', 'data': {'values': data}, 'mark': 'point', 'encoding': { 'x': {'field': 'x', 'type': 'quantitative'}, 'y': {'field': 'y', 'type': 'quantitative'} } } VegaLite(spec)
Debug
Known issues
breakingIn version 4.0.0, the import path changed from vega.widget to vega. Old code using `from vega.widget import VegaLite` will break.
fix
Change imports to `from vega import VegaLite` (or Vega).
affects: <4.0.0
gotchaThe vega package on PyPI is a Jupyter widget; it does NOT install Vega or Vega-Lite JavaScript libraries. You must install them separately (conda-forge recommended) or the widget will fail silently.
fix
Run `conda install -c conda-forge vega vega-lite` or manually include the JS via a notebook extension.
affects: all
deprecatedThe `vega` package version 3.x and earlier relied on an older widget API. The current 4.x line is incompatible with Vega-Lite 3 and below.
fix
Upgrade to vega>=4 and use Vega-Lite 4+ specifications.
affects: <4.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'vega'
The package is not installed in the current Python environment.
fix
Run `pip install vega` or `conda install -c conda-forge vega`.
ImportError: cannot import name 'VegaLite' from 'vega'
Using an older version of vega (<4.0.0) where VegaLite was in vega.widget.
fix
Upgrade vega to >=4.0.0: `pip install --upgrade vega` and use `from vega import VegaLite`.
ValueError: The truth value of a DataFrame is ambiguous
Passing a pandas DataFrame directly as data; Vega expects a list of dicts.
fix
Convert DataFrame to records: `spec['data'] = {'values': df.to_dict('records')}`.
Upgrade
Version history
4.1.0latest on PyPI · released Sep 25, 2024
Audit
Dependencies
ipywidgetsrequiredRequired for the Jupyter widget integration
traitletsrequiredUsed for widget property handling
Agent activity
30 hits · last 30 days
node
22
Amazon
2
Anthropic
1
OpenAI (training)
1
Resources
vega — pip install vega · libregistry