Trying to get Altair to work with Jupyter Notebook, I installed it using
conda install -c conda-forge altair vega_datasets notebook vega
But when I try to do an example plot
import altair as alt
from vega_datasets import data
# for the notebook only (not for JupyterLab) run this command once per session
alt.renderers.enable('notebook')
iris = data.iris()
alt.Chart(iris).mark_point().encode(
x='petalLength',
y='petalWidth',
color='species'
)
as seen in their quick start guide, I get
ValueError:
To use the 'notebook' renderer, you must install the vega package
and the associated Jupyter extension.
See https://altair-viz.github.io/getting_started/installation.html
for more information.
even though I have installed vega using Conda. I can make vega example plots though. I am unable to enable the Jupyter extension though, as Jupyter says it is incompatible.
Any help is appreciated.
Altair charts work out-of-the-box on Jupyter Notebook, JupyterLab, Zeppelin, and related notebook environments, so long as there is a web connection to load the required javascript libraries.
If the results are different, you can use Kernel -> Change Kernel in the Jupyter notebook menu to change to a kernel with a working Altair version. If that's not the case, then it is likely that you have inadvertently enabled a different renderer in one of the notebooks, for example by running alt. renderers.
Anaconda NavigatorSearch “altair” from the search field and select the library. After that click “Apply” should get Altair and its dependencies installed. You can follow the same way to install example dataset vega_datasets. Once successfully installed, go back to Home and make sure you are on the correct Environment.
For the current release of altair (Version 2.2), use
conda install -c conda-forge vega=1.3
or
pip install vega==1.3
and then restart the notebook.
The vega
python extension was mistakenly updated this week to only support vega-lite 3.0, which is not yet released and thus not yet supported by Altair.
See https://github.com/altair-viz/altair/issues/1114 for the initial bug report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With